Mailing List Archive

Distributing program for Linux
Hi,

If I write a system program which has Python >= 3.y as a dependency,
what are the options for someone whose Linux distribution provides
Python 3.x, where x < y?

I am aware that an individual user could use (mini)conda to install a
more recent version of Python in his/her home directory, but I am
interested in how root would install such a program.

Cheers,

Loris

--
This signature is currently under constuction.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Distributing program for Linux [ In reply to ]
On Tue, Mar 14, 2023 at 04:43:14PM +0100, Loris Bennett wrote:
>If I write a system program which has Python >= 3.y as a dependency,
>what are the options for someone whose Linux distribution provides
>Python 3.x, where x < y?

The docs suggest creating your own package or building and installing
from source:
https://docs.python.org/3/using/unix.html

To install from source, use ‘make altinstall’ (instead of ‘make
install’) to avoid shadowing your system Python version. The alternative
interpreter should be qualified with <major>.<minor> version, e.g.
python3.11

Depending on the package manager used by the distribution,
‘checkinstall’ could be used to build from source and install as a
package without rolling your own.
https://wiki.debian.org/CheckInstall

On Ubuntu check out the deadsnakes PPA:
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

Or use python-build from pyenv to install to a custom location:
https://github.com/pyenv/pyenv/wiki/Common-build-problems#installing-a-system-wide-python

Simon
--
https://mail.python.org/mailman/listinfo/python-list
Re: Distributing program for Linux [ In reply to ]
It?s really going to depend on the distribution and whether you have root access.

If you have Ubuntu and root access, you can add the deadsnakes repo, https://launchpad.net/~deadsnakes, and install whatever Python you want.

The default ?python3? remains but you can called a specific Python, (e.g. python3.10).

A typical shebang line would be:

#!/usr/bin/env python3.10

From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Loris Bennett <loris.bennett@fu-berlin.de>
Date: Tuesday, March 14, 2023 at 12:27 PM
To: python-list@python.org <python-list@python.org>
Subject: Distributing program for Linux
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Hi,

If I write a system program which has Python >= 3.y as a dependency,
what are the options for someone whose Linux distribution provides
Python 3.x, where x < y?

I am aware that an individual user could use (mini)conda to install a
more recent version of Python in his/her home directory, but I am
interested in how root would install such a program.

Cheers,

Loris

--
This signature is currently under constuction.
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l02A4qczH46l1ScA8yisiIwlDKh96sy16woPSOSABWqym4b6dBtHzExfFwZsnPDezDwDqaM0fdCMs3080WQQZ-b5OghOOpI$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l02A4qczH46l1ScA8yisiIwlDKh96sy16woPSOSABWqym4b6dBtHzExfFwZsnPDezDwDqaM0fdCMs3080WQQZ-b5OghOOpI$>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Distributing program for Linux [ In reply to ]
"Weatherby,Gerard" <gweatherby@uchc.edu> writes:

> It’s really going to depend on the distribution and whether you have root access.

I am interested in providing a package for people with root access for a
variety of distributions.

> If you have Ubuntu and root access, you can add the deadsnakes repo,
> https://launchpad.net/~deadsnakes, and install whatever Python you
> want.

I myself have this part covered via EasyBuild, https://easybuild.io/,
which will work on any distro. How anybody else installs a given
version Python will be left as an exercise for them (potential users of
the software are however unlikely to be using Ubuntu).

> The default ‘python3’ remains but you can called a specific Python, (e.g. python3.10).
>
> A typical shebang line would be:
>
> #!/usr/bin/env python3.10

I am currently using poetry to build the package and uses a 'scripts'
section in the pyproject.toml file to produce stubs to call the main
program. These have the shebang

#!/usr/bin/python3

So if I can get poetry to use '/usr/bin/env' instead, then I can
probably just rely on whatever mechanism other people use to switch
between Python versions to do the right thing.

Cheers,

Loris

> From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org>
> on behalf of Loris Bennett <loris.bennett@fu-berlin.de>
> Date: Tuesday, March 14, 2023 at 12:27 PM
> To: python-list@python.org <python-list@python.org>
> Subject: Distributing program for Linux
> *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
>
> Hi,
>
> If I write a system program which has Python >= 3.y as a dependency,
> what are the options for someone whose Linux distribution provides
> Python 3.x, where x < y?
>
> I am aware that an individual user could use (mini)conda to install a
> more recent version of Python in his/her home directory, but I am
> interested in how root would install such a program.
>
> Cheers,
>
> Loris
>
> --
> This signature is currently under constuction.
> --
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l02A4qczH46l1ScA8yisiIwlDKh96sy16woPSOSABWqym4b6dBtHzExfFwZsnPDezDwDqaM0fdCMs3080WQQZ-b5OghOOpI$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l02A4qczH46l1ScA8yisiIwlDKh96sy16woPSOSABWqym4b6dBtHzExfFwZsnPDezDwDqaM0fdCMs3080WQQZ-b5OghOOpI$>
--
Dr. Loris Bennett (Herr/Mr)
ZEDAT, Freie Universität Berlin
--
https://mail.python.org/mailman/listinfo/python-list
Re: Distributing program for Linux [ In reply to ]
"Loris Bennett" <loris.bennett@fu-berlin.de> writes:

> I am aware that an individual user could use (mini)conda to install a
> more recent version of Python in his/her home directory, but I am
> interested in how root would install such a program.

Root would install the script and required Python version somewhere
depending any site specific practices and then use things like pyenv,
stow, environment modules or whatever to give the users access to it.

Root might even package your script with the interpreter required into
one binary. See Tools/freeze in the source distribution.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Distributing program for Linux [ In reply to ]
Anssi Saari <as@sci.fi> writes:

> "Loris Bennett" <loris.bennett@fu-berlin.de> writes:
>
>> I am aware that an individual user could use (mini)conda to install a
>> more recent version of Python in his/her home directory, but I am
>> interested in how root would install such a program.
>
> Root would install the script and required Python version somewhere
> depending any site specific practices and then use things like pyenv,
> stow, environment modules or whatever to give the users access to it.

The program is not for normal users, but is a system program. Many
admins who might install the program will be using environment modules,
so that, coupled with setting

#!/usr/bin/env python3

for the scripts, looks like it might be a reasonable solution.

> Root might even package your script with the interpreter required into
> one binary. See Tools/freeze in the source distribution.

Well, anyone who has the sources can do that, if so inclined.
Personally, I already have enough versions of Python (currently 12
versions installed via EasyBuild plus the 2 from the OS itself) without
creating fat binaries which contain a copy of one of those version.

Cheers,

Loris

--
This signature is currently under constuction.
--
https://mail.python.org/mailman/listinfo/python-list