-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
site.getsitepackages() broken on debian #2105
Comments
The patch only applies to the system python, not the created virtual environments. |
The patch applies to virtual environments. Virtualenv>=20 on python2 has it's own site.py, which loads the system site.py and fixes up sys.path. It does however not fix python -m virtualenv -ppython2 testenv2
. testenv2/bin/activate
python -c "import site; print(site.getsitepackages())"
['/home/vagrant/mypy/testenv2/local/lib/python2.7/dist-packages', '/home/vagrant/mypy/testenv2/lib/python2.7/dist-packages'] virtualenv 20.4.4 on Ubuntu 18.04.3 LTS I already wrote a patch to fix this and am currently preparing a PR. |
What does happen in venv? |
This issue only affects python2. |
I just checked the debian patches for python3 and there they work around virtual environments by checking for the VIRTUAL_ENV environment variable: https://salsa.debian.org/cpython-team/python3/-/blob/master/debian/patches/distutils-install-layout.diff#L197 Debian doesn't do that for python2 |
The fix I came up with just replaces occurences of 'dist-packages' with 'site-packages' in getsitepackages. It's probably not the cleanest fix, but it works. A cleaner fix could be reimplementing getsitepackages in virtualenv and patching it into site. |
Ugh, seems an ugly hack for Debian lacking proper patching, but can't come up with better. |
Issue
Debian and it's derivatives patch site.getsitepackages() to use
dist-packages
directories instead ofsite-packages
directories. See https://salsa.debian.org/cpython-team/python2/-/blob/master/debian/patches/site-locations.diffThis causes site.getsitepackages() to not point to the correct directory inside virtualenvs.
I discovered this bug while looking into why virtualenv>=20 broke some mypy tests: python/mypy#10407
I'm currently preparing a PR to fix this.
Environment
pip list
of the host python wherevirtualenv
is installed:Output of the virtual environment creation
Make sure to run the creation with
-vvv --with-traceback
:The text was updated successfully, but these errors were encountered: