Skip to content

Commit

Permalink
Normalize sys.prefix for old virtualenv
Browse files Browse the repository at this point in the history
virtualenv<14 does not normalize sys.prefix correctly, so we need to do
it on our own.
  • Loading branch information
uranusjr committed Aug 6, 2021
1 parent fcadb92 commit a3b186a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pip/_internal/locations/_distutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,20 @@ def get_scheme(


def get_bin_prefix() -> str:
# XXX: In old virtualenv versions, sys.prefix can contain '..' components,
# so we need to call normpath to eliminate them.
prefix = os.path.normpath(sys.prefix)
if WINDOWS:
bin_py = os.path.join(sys.prefix, "Scripts")
bin_py = os.path.join(prefix, "Scripts")
# buildout uses 'bin' on Windows too?
if not os.path.exists(bin_py):
bin_py = os.path.join(sys.prefix, "bin")
bin_py = os.path.join(prefix, "bin")
return bin_py
# Forcing to use /usr/local/bin for standard macOS framework installs
# Also log to ~/Library/Logs/ for use with the Console.app log viewer
if sys.platform[:6] == "darwin" and sys.prefix[:16] == "/System/Library/":
if sys.platform[:6] == "darwin" and prefix[:16] == "/System/Library/":
return "/usr/local/bin"
return os.path.join(sys.prefix, "bin")
return os.path.join(prefix, "bin")


def get_purelib() -> str:
Expand Down

0 comments on commit a3b186a

Please sign in to comment.