asdf-community / asdf-python

Python plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
643 stars 55 forks source link

Module search path incorrectly includes system python installation #147

Open sirianni opened 1 year ago

sirianni commented 1 year ago
$ asdf install python 3.8.14
python-build 3.8.14 /home/sirianni/.asdf/installs/python/3.8.14
Downloading Python-3.8.14.tar.xz...
-> https://www.python.org/ftp/python/3.8.14/Python-3.8.14.tar.xz
Installing Python-3.8.14...
Installed Python-3.8.14 to /home/sirianni/.asdf/installs/python/3.8.14
$ /home/sirianni/.asdf/installs/python/3.8.14/bin/python -c 'import sys; print("\n".join(sys.path));'

/home/sirianni/.asdf/installs/python/3.8.14/lib/python38.zip
/home/sirianni/.asdf/installs/python/3.8.14/lib/python3.8
/home/sirianni/.asdf/installs/python/3.8.14/lib/python3.8/lib-dynload
/home/sirianni/.local/lib/python3.8/site-packages
/home/sirianni/.asdf/installs/python/3.8.14/lib/python3.8/site-packages

Note that sys.path incorrectly includes /home/sirianni/.local/lib/python3.8/site-packages which is from the system python installation.

sirianni commented 1 year ago

It seems that python's site.py will dynamically add ~/.local/lib/... to sys.path if there is a matching python version. This can be disabled by setting the environment variable PYTHONNOUSERSITE=1.