Description
In #8387 virtualenv was pinned to <20 to fix failing tests.
virtualenv <20 will be broken by python 3.10. Therefor I tried to unpin it. I haven't quite managed to make it work yet, but found the cause of the problem and wanted to document my findings.
testpep561 creates a virtualenv, installs some packages into it and then runs mypy, while telling it to search for stub packages in that virtualenv.
At first I couldn't reproduce the error. As it turns out it is related to the patches debian (and it's derivates) apply to python.
virtualenv<20 ships it's own site.py file to build sys.path. This site.py file doesn't contain the getsitepackages
and getusersitepackages
methods, causing mypy's sitepkgs.py
to fall back to using distutils to get the python library path.
This works.
virtualenv>=20 doesn't ship it's own site.py file, so the python site.py file is used. Debian patches this file to return paths ending in dist-packages
instead of site-packages
. Pip in a virtualenv however still installs to site-packages
, causing mypy to not find the installed packages.
This is only a problem with python2. Debian doesn't seem to patch python3 site.py in this way.