diff --git a/news/7718.bugfix b/news/7718.bugfix new file mode 100644 index 00000000000..5abcce69a83 --- /dev/null +++ b/news/7718.bugfix @@ -0,0 +1,2 @@ +Correctly detect global site-packages availability of virtual environments +created by PyPA’s virtualenv>=20.0. diff --git a/src/pip/_internal/utils/virtualenv.py b/src/pip/_internal/utils/virtualenv.py index d81e6ac54bb..596a69a7dad 100644 --- a/src/pip/_internal/utils/virtualenv.py +++ b/src/pip/_internal/utils/virtualenv.py @@ -105,11 +105,12 @@ def virtualenv_no_global(): # type: () -> bool """Returns a boolean, whether running in venv with no system site-packages. """ + # PEP 405 compliance needs to be checked first since virtualenv >=20 would + # return True for both checks, but is only able to use the PEP 405 config. + if _running_under_venv(): + return _no_global_under_venv() if _running_under_regular_virtualenv(): return _no_global_under_regular_virtualenv() - if _running_under_venv(): - return _no_global_under_venv() - return False