How to package a Python command line app?

Manfred Lotz ml_news at posteo.de
Wed Dec 8 11:47:00 EST 2021


Hi Loris,

On Wed, 08 Dec 2021 15:38:48 +0100
"Loris Bennett" <loris.bennett at fu-berlin.de> wrote:

> Hi Manfred,
> 
> Manfred Lotz <ml_news at posteo.de> writes:
> 
> > The are many possibilities to package a Python app, and I have to
> > admit I am pretty confused.
> >
> > Here is what I have:
> >
> > A Python command line app which requires some packages which are
> > not in the standard library.
> >
> > I am on Linux and like to have an executable (perhaps a zip file
> > with a shebang; whatever) which runs on different Linux systems.
> >
> > Different mean
> > - perhaps different glibc versions
> > - perhaps different Python versions
> >
> > In my specific case this is: 
> > - RedHat 8.4 with Python 3.6.8
> > - Ubuntu 20.04 LTS with Python 3.8.10 
> > - and finally Fedora 33 with Python 3.9.9
> >
> >
> > Is this possible to do? If yes which tool would I use for this?  
> 
> I use poetry[1] on CentOS 7 to handle all the dependencies and create
> a wheel which I then install to a custom directory with pip3.
> 
> You would checkout the repository with your code on the target system,
> start a poetry shell using the Python version required, and then build
> the wheel.  From outside the poetry shell you can set PYTHONUSERBASE
> and then install with pip3.  You then just need to set PYTHONPATH
> appropriately where ever you want to use your software.
> 

In my case it could happen that I do not have access to the target
system but wants to handover the Python app to somebody else. This
person wants just to run it.


> Different Python versions shouldn't be a problem.  If some module
> depends on a specific glibc version, then you might end up in standard
> dependency-hell territory, but you can pin module versions of
> dependencies in poetry, and you could also possibly use different
> branches within your repository to handle that.
> 

I try to avoid using modules which depeng on specific glibc. 

Although, it seems that it doesn't really help for my use case I will
play with poetry to get a better understanding of its capabilities.

-- 
Thanks a lot,
Manfred





More information about the Python-list mailing list