Skip to content

Commit

Permalink
Swap venv and virtualenv checks
Browse files Browse the repository at this point in the history
Environments created by pypa/virtualenv >=20 can pass both real_prefix
and base_prefix checks, but are only able to use the pyvenv.cfg values,
not the legacy `no-global-site-packages.txt`. So we need to check for
venv (PEP 405) first.
  • Loading branch information
uranusjr committed Feb 11, 2020
1 parent 723b845 commit 6104060
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions news/7718.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Correctly detect global site-packages availability of virtual environments
created by PyPA’s virtualenv>=20.0.
7 changes: 4 additions & 3 deletions src/pip/_internal/utils/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6104060

Please sign in to comment.