Michal Cyprian wrote:

there is a long-standing problem that `sudo pip install` cannot be safely used 
in Fedora. Many users don't know about this and break python packages on theirs 
systems. Packages installed using this command can conflict and overwrite 
Python rpm packages.
This is a major problem and we have seen several systems broken by people using "sudo 
pip". Unfortunately, telling people to not use it will not work: "sudo pip" appears 
in documentation of too many projects online.

The default install location of pip/distutils-installed packages depends on the 
value of the
  sys.prefix variable [4].

But this default can be trivially changed by distro.

There were several discussions on Bugzilla [1] and the pypa-dev mailing list 
[2].
Interesting solutions were conceived at the CPython level:
     - addition of sys.local_prefix [2]
     - simplification of CPython startup sequence [4]
Unfortunately none of them were realized and both solutions require many 
changes of Python and Python Standard Library.

But you don't need to do either.

One can probably either modify python package itself or create another one with two files with following contents:

/usr/lib64/pythonX.Y/distutils/distutils.cfg:

        [install]
        install-lib = /usr/local/lib/pythonX.Y

/usr/lib64/pythonX.Y/sitecustomize.py:

        import site
        site.addsitedir('/usr/local/lib/pythonX.Y')

Or whatever custom-packages directory you want to redirect it to.

That's it. First file will change default location of installed packages. Second one will add it to site dirs to support imports from those local packages. Maybe sitecustomize.py will need few tweaks to sitedirs order to make it work better.

This is documented in "legacy" section of python docs on distutils:

https://docs.python.org/3.5/install/#custom-installation

--
Zart

_______________________________________________
python-devel mailing list -- python-devel@lists.fedoraproject.org
To unsubscribe send an email to python-devel-le...@lists.fedoraproject.org

Reply via email to