Issue
Hello up there. I've discovered that with python2 virtualenv 20 does not process .pth files under site-packages if $PYTHONPATH points to site-packages directory. It is a regression compared to virtualenv 16. This causes testing breakage of real projects, for example pygolong tox tests with new virtualenv become broken due to this issue.
Below is a brief demonstration for the problem:
# create virtualenv with python2 and install zope.interfaces
kirr@deco:~/tmp/trashme$ virtualenv -p python2 x.venv
created virtual environment CPython2.7.18.final.0-64 in 134ms
creator CPython2Posix(dest=/home/kirr/tmp/trashme/x.venv, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kirr/.local/share/virtualenv)
added seed packages: pip==20.1.1, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator
kirr@deco:~/tmp/trashme$ unset PYTHONPATH
kirr@deco:~/tmp/trashme$ . x.venv/bin/activate
(x.venv) kirr@deco:~/tmp/trashme$ pip install zope.interface
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting zope.interface
Using cached zope.interface-5.1.1-cp27-cp27mu-manylinux2010_x86_64.whl (232 kB)
Requirement already satisfied: setuptools in ./x.venv/lib/python2.7/site-packages (from zope.interface) (44.1.1)
Installing collected packages: zope.interface
Successfully installed zope.interface-5.1.1
# make sure `import zope.interfaces` works
(x.venv) kirr@deco:~/tmp/trashme$ python
Python 2.7.18 (default, Apr 20 2020, 20:30:41)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface
>>> import zope
>>> zope.__path__
['/home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/zope']
# set $PYTHONPATH to site-packages and retry importing zope.interfaces
# -> `import zope` fails
(x.venv) kirr@deco:~/tmp/trashme$ PYTHONPATH=/home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages python
Python 2.7.18 (default, Apr 20 2020, 20:30:41)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zope.interface
>>> import zope
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zope
The issue happens due to below check of if full_path not in sys.path in
|
site_packages = r""" |
|
___EXPECTED_SITE_PACKAGES___ |
|
""" |
|
import json |
|
|
|
add_site_dir = sys.modules["site"].addsitedir |
|
for path in json.loads(site_packages): |
|
full_path = os.path.abspath(os.path.join(here, path.encode("utf-8"))) |
|
if full_path not in sys.path: |
|
add_site_dir(full_path) |
which, in the presence of namespace packages (packages that are only installed via .pth files, not via __init__.py) leads to ImportError for those packages. For the reference here are corresponding directory and .pth for zope.interfaces:
# no __init__.py here
(x.venv) kirr@deco:~/tmp/trashme$ ll x.venv/lib/python2.7/site-packages/zope
итого 4
drwxr-xr-x 4 kirr kirr 4096 окт 1 13:52 interface
# zope/interface/ has __init__.py
(x.venv) kirr@deco:~/tmp/trashme$ ll x.venv/lib/python2.7/site-packages/zope/interface/
итого 716
-rw-r--r-- 1 kirr kirr 24296 окт 1 13:52 adapter.py
-rw-r--r-- 1 kirr kirr 19533 окт 1 13:52 adapter.pyc
-rw-r--r-- 1 kirr kirr 7612 окт 1 13:52 advice.py
-rw-r--r-- 1 kirr kirr 5588 окт 1 13:52 advice.pyc
drwxr-xr-x 3 kirr kirr 4096 окт 1 13:52 common
-rw-r--r-- 1 kirr kirr 5191 окт 1 13:52 _compat.py
-rw-r--r-- 1 kirr kirr 5572 окт 1 13:52 _compat.pyc
-rw-r--r-- 1 kirr kirr 40800 окт 1 13:52 declarations.py
-rw-r--r-- 1 kirr kirr 33053 окт 1 13:52 declarations.pyc
-rw-r--r-- 1 kirr kirr 4052 окт 1 13:52 document.py
-rw-r--r-- 1 kirr kirr 3685 окт 1 13:52 document.pyc
-rw-r--r-- 1 kirr kirr 8643 окт 1 13:52 exceptions.py
-rw-r--r-- 1 kirr kirr 8553 окт 1 13:52 exceptions.pyc
-rw-r--r-- 1 kirr kirr 1056 окт 1 13:52 _flatten.py
-rw-r--r-- 1 kirr kirr 690 окт 1 13:52 _flatten.pyc
-rw-r--r-- 1 kirr kirr 3623 окт 1 13:52 __init__.py
-rw-r--r-- 1 kirr kirr 3063 окт 1 13:52 __init__.pyc
-rw-r--r-- 1 kirr kirr 39746 окт 1 13:52 interface.py
-rw-r--r-- 1 kirr kirr 31201 окт 1 13:52 interface.pyc
-rw-r--r-- 1 kirr kirr 51475 окт 1 13:52 interfaces.py
-rw-r--r-- 1 kirr kirr 62975 окт 1 13:52 interfaces.pyc
-rw-r--r-- 1 kirr kirr 23454 окт 1 13:52 registry.py
-rw-r--r-- 1 kirr kirr 24610 окт 1 13:52 registry.pyc
-rw-r--r-- 1 kirr kirr 23094 окт 1 13:52 ro.py
-rw-r--r-- 1 kirr kirr 21215 окт 1 13:52 ro.pyc
drwxr-xr-x 2 kirr kirr 4096 окт 1 13:52 tests
-rw-r--r-- 1 kirr kirr 8420 окт 1 13:52 verify.py
-rw-r--r-- 1 kirr kirr 5399 окт 1 13:52 verify.pyc
-rw-r--r-- 1 kirr kirr 57952 окт 1 13:52 _zope_interface_coptimizations.c
-rwxr-xr-x 1 kirr kirr 142632 окт 1 13:52 _zope_interface_coptimizations.so
# the nspkg.pth file
(x.venv) kirr@deco:~/tmp/trashme$ cat x.venv/lib/python2.7/site-packages/zope.interface-5.1.1-py2.7-nspkg.pth
import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('zope',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('zope', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('zope', [os.path.dirname(p)])));m = m or sys.modules.setdefault('zope', types.ModuleType('zope'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
As said above this leads to pygolang tox tests failure, e.g.
(venv20.venv) kirr@deco:~/src/tools/go/pygolang-master$ tox -e py27-thread
...
===================================================== test session starts ======================================================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py27-thread/.pytest_cache
rootdir: /home/kirr/src/tools/go/pygolang-master
collected 112 items
gpython/gpython_test.py ssssss.sssssss [ 12%]
golang/_gopath_test.py .. [ 14%]
golang/context_test.py .. [ 16%]
golang/cxx_test.py .. [ 17%]
golang/errors_test.py ........ [ 25%]
golang/fmt_test.py ... [ 27%]
golang/golang_test.py ................F........................FFF.... [ 70%]
golang/io_test.py . [ 71%]
golang/strconv_test.py .. [ 73%]
golang/strings_test.py ..... [ 77%]
golang/sync_test.py ............. [ 89%]
golang/time_test.py ........ [ 96%]
golang/pyx/build_test.py FFF [ 99%]
golang/pyx/runtime_test.py . [100%]
=========================================================== FAILURES ===========================================================
________________________________________________________ test_go_leaked ________________________________________________________
def test_go_leaked():
> pyrun([dir_testprog + "/golang_test_goleaked.py"])
golang/golang_test.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
argv = ['/home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/testprog/golang_test_goleak ed.py']
stdin = None, stdout = None, stderr = None, kw = {}, retcode = 1
def pyrun(argv, stdin=None, stdout=None, stderr=None, **kw):
retcode, stdout, stderr = _pyrun(argv, stdin=stdin, stdout=stdout, stderr=stderr, **kw)
if retcode:
> raise RuntimeError(' '.join(argv) + '\n' + (stderr and str(stderr) or '(failed)'))
E RuntimeError: /home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/testprog/g olang_test_goleaked.py
E (failed)
golang/golang_test.py:1836: RuntimeError
----------------------------------------------------- Captured stderr call -----------------------------------------------------
Error in sys.excepthook:
Traceback (most recent call last):
File "/home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/__init__.py", line 243, in _ print_exception
file = sys.stderr
AttributeError: 'NoneType' object has no attribute 'stderr'
Original exception was:
Traceback (most recent call last):
File "/home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/testprog/golang_test_goleake d.py", line 24, in <module>
from golang import go, chan
File "/home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/__init__.py", line 303, in < module>
import golang._patch.pytest_py2
File "/home/kirr/src/tools/go/pygolang-master/.tox/py27-thread/lib/python2.7/site-packages/golang/_patch/__init__.py", line 25 , in <module>
from peak.util import imports # thanks PJE
ImportError: No module named peak.util
...
Thanks beforehand,
Kirill
Environment
Provide at least:
- OS: Debian GNU/Linux testing.
Linux deco 5.8.0-2-amd64 #1 SMP Debian 5.8.10-1 (2020-09-19) x86_64 GNU/Linux
pip list of the host python where virtualenv is installed:
Details
kirr@deco:~$ pip list
Package Version
-------------------- --------------
appdirs 1.4.4
asciinema 2.0.2
atomicwrites 1.4.0
attrs 19.3.0
backcall 0.2.0
beautifulsoup4 4.9.1
bleach 3.1.5
blinker 1.4
breezy 3.1.0
Brlapi 0.7.0
brz-etckeeper 0.0.0
certifi 2020.6.20
chardet 3.0.4
colorama 0.4.3
configobj 5.0.6
cryptography 3.1
cupshelpers 1.0
cycler 0.10.0
dblatex 0.3.11py3
dbus-python 1.2.16
decorator 4.4.2
Deprecated 1.2.10
devscripts 2.20.4
distlib 0.3.1
distro 1.5.0
docutils 0.16
dulwich 0.20.2
fastimport 0.9.8
feedparser 5.2.1
filelock 3.0.12
flake8 3.8.3
gevent 1.4.0
gpg 1.14.0-unknown
greenlet 0.4.15
gyp 0.1
html5lib 1.0.1
httplib2 0.18.1
idna 2.10
img2pdf 0.4.0
importlib-metadata 1.6.0
iotop 0.6
ipython 7.18.1
ipython-genutils 0.2.0
jedi 0.17.0
jeepney 0.4.3
keyring 21.3.0
kiwisolver 1.2.0
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.5
libvirt-python 6.1.0
louis 3.15.0
lxml 4.5.2
Markdown 3.2.2
Markups 3.0.0
matplotlib 3.3.2
mccabe 0.6.1
meld 3.20.2
mercurial 5.5.1
meson 0.55.3
more-itertools 4.2.0
mpmath 1.1.0
musicbrainzngs 0.7.1
mutagen 1.45.1
mypy 0.782
mypy-extensions 0.4.3
notify2 0.3
numpy 1.19.1
oauthlib 3.1.0
olefile 0.46
packaging 20.4
parso 0.7.0
patiencediff 0.1.0
pdfarranger 1.6.2
pexpect 4.6.0
pickleshare 0.7.5
pikepdf 1.17.3+dfsg
Pillow 7.2.0
pip 20.1.1
pkginfo 1.4.2
pluggy 0.13.0
prompt-toolkit 3.0.7
psutil 5.7.2
pulsemixer 1.5.1
py 1.9.0
pycairo 1.16.2
pycodestyle 2.6.0
pycups 2.0.1
pycurl 7.43.0.6
pyflakes 2.2.0
pygame 1.9.6
PyGithub 1.43.7
Pygments 2.3.1
PyGObject 3.38.0
pyinotify 0.9.6
PyJWT 1.7.1
PyMuPDF 1.17.4
pyparsing 2.4.7
PyQt5 5.15.0
PyQtWebEngine 5.15.0
PySimpleSOAP 1.16.2
pysmbc 1.0.22
pytest 4.6.11
python-apt 2.1.3
python-dateutil 2.8.1
python-debian 0.1.37
python-debianbts 3.0.2
python-gitlab 2.4.0
python-ly 0.9.6
python-magic 0.4.16
python-markdown-math 0.7
python-poppler-qt5 0.75.0
pyxattr 0.6.1
pyxdg 0.26
PyYAML 5.3.1
quodlibet 4.3.0
readme-renderer 24.0
regex 2020.7.14
reportbug 7.7.0
reportlab 3.5.49
requests 2.23.0
requests-toolbelt 0.8.0
rfc3986 1.4.0
roman 2.0.0
scour 0.37
SecretStorage 3.1.2
setuptools 49.3.1
simplejson 3.17.0
sip 4.19.24
six 1.15.0
soupsieve 2.0.1
sympy 1.6.2
textile 4.0.1
tqdm 4.48.2
traitlets 5.0.4
twine 3.2.0
typed-ast 1.4.1
typing-extensions 3.7.4.2
unidiff 0.5.5
urllib3 1.25.9
virtualenv 20.0.29+ds
wadllib 1.3.4
wcwidth 0.1.9
webencodings 0.5.1
wheel 0.34.2
wrapt 1.11.2
youtube-dl 2020.9.14
zipp 1.0.0
Output of the virtual environment creation
Make sure to run the creation with -vvv --with-traceback:
Details
kirr@deco:~/tmp/trashme$ virtualenv -p python2 -vvv --with-traceback x.venv
34 setup logging to NOTSET [DEBUG report:43]
58 find interpreter for spec PythonSpec(implementation=CPython, major=2) [INFO builtin:44]
58 proposed PythonInfo(spec=CPython3.8.6.final.0-64, exe=/usr/bin/python3, platform=linux, version='3.8.6 (default, Sep 25 2020, 09:36:53) \n[GCC 10.2.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:50]
58 discover PATH[0]=/home/kirr/Files/kirr-setup/bin [DEBUG builtin:84]
59 filesystem is case-sensitive [DEBUG info:28]
59 discover PATH[1]=/home/kirr/navytux/bin [DEBUG builtin:84]
59 discover PATH[2]=/home/kirr/local/tig/bin [DEBUG builtin:84]
59 discover PATH[3]=/home/kirr/src/tools/go/go/bin [DEBUG builtin:84]
60 discover PATH[4]=/home/kirr/src/tools/git/git-cinnabar [DEBUG builtin:84]
60 discover PATH[5]=/home/kirr/src/tools/txt/docutils/docutils/tools [DEBUG builtin:84]
60 discover PATH[6]=/home/kirr/bin [DEBUG builtin:84]
60 discover PATH[7]=/usr/local/bin [DEBUG builtin:84]
60 discover PATH[8]=/usr/bin [DEBUG builtin:84]
61 Attempting to acquire lock 140435179566080 on /home/kirr/.local/share/virtualenv/py_info/1/f92b2924b84ff19c1c3dc485f7644d4486f64738191026bf8e6de303969141b5.lock [DEBUG filelock:270]
61 Lock 140435179566080 acquired on /home/kirr/.local/share/virtualenv/py_info/1/f92b2924b84ff19c1c3dc485f7644d4486f64738191026bf8e6de303969141b5.lock [INFO filelock:274]
61 got python info of /usr/bin/python2 from /home/kirr/.local/share/virtualenv/py_info/1/f92b2924b84ff19c1c3dc485f7644d4486f64738191026bf8e6de303969141b5.json [DEBUG via_disk_folder:133]
62 Attempting to release lock 140435179566080 on /home/kirr/.local/share/virtualenv/py_info/1/f92b2924b84ff19c1c3dc485f7644d4486f64738191026bf8e6de303969141b5.lock [DEBUG filelock:315]
62 Lock 140435179566080 released on /home/kirr/.local/share/virtualenv/py_info/1/f92b2924b84ff19c1c3dc485f7644d4486f64738191026bf8e6de303969141b5.lock [INFO filelock:318]
62 proposed PathPythonInfo(spec=CPython2.7.18.final.0-64, exe=/usr/bin/python2, platform=linux2, version='2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]', encoding_fs_io=UTF-8-None) [INFO builtin:50]
62 accepted PathPythonInfo(spec=CPython2.7.18.final.0-64, exe=/usr/bin/python2, platform=linux2, version='2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]', encoding_fs_io=UTF-8-None) [DEBUG builtin:52]
87 create virtual environment via CPython2Posix(dest=/home/kirr/tmp/trashme/x.venv, clear=False, global=False) [INFO session:52]
87 create folder /home/kirr/tmp/trashme/x.venv/bin [DEBUG _sync:25]
88 create folder /home/kirr/tmp/trashme/x.venv/include [DEBUG _sync:25]
88 create folder /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages [DEBUG _sync:25]
88 write /home/kirr/tmp/trashme/x.venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
88 home = /usr [DEBUG pyenv_cfg:38]
88 implementation = CPython [DEBUG pyenv_cfg:38]
88 version_info = 2.7.18.final.0 [DEBUG pyenv_cfg:38]
88 virtualenv = 20.0.29+ds [DEBUG pyenv_cfg:38]
88 include-system-site-packages = false [DEBUG pyenv_cfg:38]
88 base-prefix = /usr [DEBUG pyenv_cfg:38]
88 base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
88 base-executable = /usr/bin/python2 [DEBUG pyenv_cfg:38]
88 copy /usr/bin/python2 to /home/kirr/tmp/trashme/x.venv/bin/python [DEBUG _sync:52]
91 symlink /usr/lib/python2.7/os.py to /home/kirr/tmp/trashme/x.venv/lib/python2.7/os.py [DEBUG _sync:44]
91 symlink /usr/lib/python2.7/os.pyc to /home/kirr/tmp/trashme/x.venv/lib/python2.7/os.pyc [DEBUG _sync:44]
91 symlink directory /usr/include/python2.7 to /home/kirr/tmp/trashme/x.venv/include/python2.7 [DEBUG _sync:44]
91 symlink /usr/lib/python2.7/config-x86_64-linux-gnu/Makefile to /home/kirr/tmp/trashme/x.venv/lib/python2.7/config-x86_64-linux-gnu/Makefile [DEBUG _sync:44]
91 symlink directory /usr/lib/python2.7/lib-dynload to /home/kirr/tmp/trashme/x.venv/lib/python2.7/lib-dynload [DEBUG _sync:44]
91 create virtualenv import hook file /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/_virtualenv.pth [DEBUG api:94]
92 create /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/_virtualenv.py [DEBUG api:97]
92 ============================== target debug ============================== [DEBUG session:54]
92 debug via /home/kirr/tmp/trashme/x.venv/bin/python /usr/lib/python3/dist-packages/virtualenv/create/debug.py [DEBUG creator:209]
92 {
"sys": {
"executable": "/home/kirr/tmp/trashme/x.venv/bin/python",
"_base_executable": null,
"prefix": "/home/kirr/tmp/trashme/x.venv",
"base_prefix": "/usr",
"real_prefix": "/usr",
"exec_prefix": "/home/kirr/tmp/trashme/x.venv",
"base_exec_prefix": "/usr",
"path": [
"/home/kirr/src/tools/txt/docutils/docutils",
"/usr/lib/python2.7",
"/usr/lib/python2.7/plat-x86_64-linux-gnu",
"/usr/lib/python2.7/lib-tk",
"/usr/lib/python2.7/lib-old",
"/usr/lib/python2.7/lib-dynload",
"/home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages"
],
"meta_path": [
"<class '_virtualenv._VirtualenvImporter'>"
],
"fs_encoding": "UTF-8",
"io_encoding": null
},
"version": "2.7.18 (default, Apr 20 2020, 20:30:41) \n[GCC 9.3.0]",
"makefile_filename": "/usr/lib/python2.7/config-x86_64-linux-gnu/Makefile",
"os": "<module 'os' from '/usr/lib/python2.7/os.pyc'>",
"site": "<module 'site' from '/usr/lib/python2.7/site.pyc'>",
"datetime": "<module 'datetime' (built-in)>",
"math": "<module 'math' (built-in)>",
"json": "<module 'json' from '/usr/lib/python2.7/json/__init__.pyc'>"
} [DEBUG session:55]
106 add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kirr/.local/share/virtualenv) [INFO session:59]
109 got embed update of distribution wheel from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/wheel.json [DEBUG via_disk_folder:133]
109 got embed update of distribution setuptools from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/setuptools.json [DEBUG via_disk_folder:133]
109 got embed update of distribution pip from /home/kirr/.local/share/virtualenv/wheel/2.7/embed/1/pip.json [DEBUG via_disk_folder:133]
111 using periodically updated wheel /home/kirr/.local/share/virtualenv/wheel/house/wheel-0.35.1-py2.py3-none-any.whl [DEBUG periodic_update:53]
112 using periodically updated wheel /home/kirr/.local/share/virtualenv/wheel/house/setuptools-44.1.1-py2.py3-none-any.whl [DEBUG periodic_update:53]
112 install pkg_resources from wheel /usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
112 install pip from wheel /usr/share/python-wheels/pip-20.1.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
112 Attempting to acquire lock 140435177003520 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any.lock [DEBUG filelock:270]
112 install wheel from wheel /home/kirr/.local/share/virtualenv/wheel/house/wheel-0.35.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
113 Attempting to acquire lock 140435177002848 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any.lock [DEBUG filelock:270]
113 install setuptools from wheel /home/kirr/.local/share/virtualenv/wheel/house/setuptools-44.1.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
113 Attempting to acquire lock 140435177003808 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:270]
113 Lock 140435177003520 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any.lock [INFO filelock:274]
113 Lock 140435177002848 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any.lock [INFO filelock:274]
113 Attempting to acquire lock 140435177003904 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [DEBUG filelock:270]
113 Lock 140435177003808 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:274]
113 Lock 140435177003904 acquired on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [INFO filelock:274]
114 Attempting to release lock 140435177003808 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:315]
114 Attempting to release lock 140435177003520 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any.lock [DEBUG filelock:315]
114 Attempting to release lock 140435177002848 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any.lock [DEBUG filelock:315]
114 Lock 140435177003808 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:318]
114 Attempting to release lock 140435177003904 on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [DEBUG filelock:315]
114 Lock 140435177003520 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any.lock [INFO filelock:318]
114 Lock 140435177002848 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any.lock [INFO filelock:318]
114 Lock 140435177003904 released on /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any.lock [INFO filelock:318]
115 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/wheel [DEBUG _sync:52]
115 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any/pkg_resources-0.0.0.virtualenv to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pkg_resources-0.0.0.virtualenv [DEBUG _sync:52]
115 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any/pip-20.1.1.dist-info to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pip-20.1.1.dist-info [DEBUG _sync:52]
115 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/setuptools [DEBUG _sync:52]
116 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any/pkg_resources-0.0.0.dist-info to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pkg_resources-0.0.0.dist-info [DEBUG _sync:52]
121 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pkg_resources-0.0.0-py2.py3-none-any/pkg_resources to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pkg_resources [DEBUG _sync:52]
122 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any/pip-20.1.1.virtualenv to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pip-20.1.1.virtualenv [DEBUG _sync:52]
123 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/pip-20.1.1-py2.py3-none-any/pip to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pip [DEBUG _sync:52]
127 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel-0.35.1.dist-info to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/wheel-0.35.1.dist-info [DEBUG _sync:52]
131 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/wheel-0.35.1-py2.py3-none-any/wheel-0.35.1.virtualenv to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/wheel-0.35.1.virtualenv [DEBUG _sync:52]
133 generated console scripts [DEBUG base:48]
134 generated console scripts wheel2.7 wheel-2.7 wheel wheel2 [DEBUG base:48]
144 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools-44.1.1.virtualenv to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/setuptools-44.1.1.virtualenv [DEBUG _sync:52]
144 copy /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/easy_install.py to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/easy_install.py [DEBUG _sync:52]
145 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/pkg_resources to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/pkg_resources [DEBUG _sync:52]
149 copy directory /home/kirr/.local/share/virtualenv/wheel/2.7/image/1/CopyPipInstall/setuptools-44.1.1-py2.py3-none-any/setuptools-44.1.1.dist-info to /home/kirr/tmp/trashme/x.venv/lib/python2.7/site-packages/setuptools-44.1.1.dist-info [DEBUG _sync:52]
152 generated console scripts easy_install-2.7 easy_install2 easy_install easy_install2.7 [DEBUG base:48]
174 generated console scripts pip2.7 pip pip2 pip-2.7 [DEBUG base:48]
174 add activators for Bash, CShell, Fish, PowerShell, Python [INFO session:64]
175 write /home/kirr/tmp/trashme/x.venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
176 home = /usr [DEBUG pyenv_cfg:38]
176 implementation = CPython [DEBUG pyenv_cfg:38]
176 version_info = 2.7.18.final.0 [DEBUG pyenv_cfg:38]
176 virtualenv = 20.0.29+ds [DEBUG pyenv_cfg:38]
176 include-system-site-packages = false [DEBUG pyenv_cfg:38]
176 base-prefix = /usr [DEBUG pyenv_cfg:38]
176 base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
176 base-executable = /usr/bin/python2 [DEBUG pyenv_cfg:38]
176 created virtual environment CPython2.7.18.final.0-64 in 143ms
creator CPython2Posix(dest=/home/kirr/tmp/trashme/x.venv, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kirr/.local/share/virtualenv)
added seed packages: pip==20.1.1, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator [WARNING __main__:17]
Issue
Hello up there. I've discovered that with python2 virtualenv 20 does not process .pth files under site-packages if $PYTHONPATH points to site-packages directory. It is a regression compared to virtualenv 16. This causes testing breakage of real projects, for example pygolong tox tests with new virtualenv become broken due to this issue.
Below is a brief demonstration for the problem:
The issue happens due to below check of
if full_path not in sys.pathinvirtualenv/src/virtualenv/create/via_global_ref/builtin/python2/site.py
Lines 47 to 56 in 5e46e4a
which, in the presence of namespace packages (packages that are only installed via .pth files, not via
__init__.py) leads to ImportError for those packages. For the reference here are corresponding directory and .pth for zope.interfaces:As said above this leads to pygolang tox tests failure, e.g.
Thanks beforehand,
Kirill
Environment
Provide at least:
Linux deco 5.8.0-2-amd64 #1 SMP Debian 5.8.10-1 (2020-09-19) x86_64 GNU/Linuxpip listof the host python wherevirtualenvis installed:Details
Output of the virtual environment creation
Make sure to run the creation with
-vvv --with-traceback:Details