Hello,
I’m not sure whether to discuss this on the setuptool, distutils or pip tracker, so I’ll ask here.
The distutils (and so, setuptools) install has the concept of install schemes, which control where a package gets installed: system-wide, or to a user’s home.
For a long time, Debian has a patch, distutils-install-layout.diff that adds more install shcemes, unix_local
and deb_system
, and implements logic to select them. The unix_local
scheme installs to /usr/local
rather than /usr
.
Fedora does a similar thing in a more hacky/minimal (depending on your point of view) way. It also changes the install prefix from /usr/
to /usr/local
, in the default case.
These patches assume that the stdlib is tied to an interpreter and can’t be changed. Now that setuptools is replacing stdlib distutils with its own copy, these customizations are starting to disappear.
Is there a supported way to do customizations like this?
I can describe Fedora’s reasons for the patch: it’s to minimize damage to the system caused by sudo pip
.
Since critical software including the system package manager is written in Python, when sudo pip install
updates a library to an incompatible version, the package manager can stop working. And unfortunately, the Internet is full of advice telling people to use sudo pip
.
The solution in Fedora is to:
- install system software (from RPMs) in
/usr
- make
pip
(i.e. distutils) install to/usr/local
- in
site.py
, put both/usr/lib*/python*
and/usr/local/lib*/python*
(and their site-packages) onsys.path
System software then uses Python’s-I
option, which skips site customization and thus omit the/usr/local
, so it’s not affected by changes fromsudo pip
.
If newer setuptools replace distutils with its own version using a .pth
file, the following can happen:
-
sudo pip install -U setuptools
, putting an unpatched copy ofdistutils
in/usr/local
-
sudo pip install -U ...
, which installs to/usr
directly, possibly breaking system software.
Is there any supported way to solve the this issue?