You are not logged in.

#1 2023-01-27 00:42:47

mnot
Member
From: Melbourne, Australia
Registered: 2015-10-14
Posts: 11
Website

Python application packaging best practice

I've noticed that Python-based applications (i.e., things called from shell that happen to be implemented in Python) are often packaged in such a way that they write into the global Python site-packages. For example:

- certbot
- ansible
- ansible-lint

... and I suspect many more.

Installing these in their own, isolated virtual environments (e.g., using pipx) seems like it would be better practice, assuring that conflicts with other requirements could be avoided.

Has this been discussed before?

Offline

#2 2023-01-27 11:25:59

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: Python application packaging best practice

Yup, many times.
Usually triggered by conflicts between pacman-maintained stuff & maintained-by-other-package-manager stuff .

The consensus is that archlinux packages are intended to be used systemwide and should use systemwide folders .
Isolated virtual environments are great for users and should be maintained by users .

https://wiki.archlinux.org/title/Python … management and https://wiki.archlinux.org/title/Python … guidelines should help to give more insight.

Last edited by Lone_Wolf (2023-01-27 11:26:28)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2023-01-30 00:02:57

mnot
Member
From: Melbourne, Australia
Registered: 2015-10-14
Posts: 11
Website

Re: Python application packaging best practice

Thx.

I suspect one day a conflict between different pacman-maintained packages will surface, but *shrug*.

Cheers,

Offline

#4 2023-01-30 01:18:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Python application packaging best practice

How could pacman-maintained packages conflict?  The path includes the package name.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2023-01-30 03:09:39

mnot
Member
From: Melbourne, Australia
Registered: 2015-10-14
Posts: 11
Website

Re: Python application packaging best practice

If all dependencies are installed through pacman, they won't. Never mind -- this makes sense to me now. Still not a _huge_ fan of having pacman-managed Python packages installed into the system site_packages; it's difficult to distinguish them from packages that were installed by pip.

Offline

#6 2023-01-30 03:16:10

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: Python application packaging best practice

Unless you only use pip for user installed packages.

Online

#7 2023-01-30 03:20:17

mnot
Member
From: Melbourne, Australia
Registered: 2015-10-14
Posts: 11
Website

Re: Python application packaging best practice

Sure -- but that's something people have to learn (and then implement with eg PIP_REQUIRE_VIRTUALENV=true). Until then, this is a bit of a footgun just lying around.

Offline

#8 2023-01-30 03:36:06

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: Python application packaging best practice

AFAIK, pip defaults to user installs now, unless you override it.

Online

#9 2023-01-30 04:00:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Python application packaging best practice

Nothing about those concerns are in any way specific to python.

If one installs *any* software as root / system-wide bypassing pacman they're prone to run into conflicts.

The concern should not be with packaged files being placed in the system-wide site-packages directory, but only unpackaged files being placed there.

Last edited by Trilby (2023-01-30 04:01:07)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB