Skip to content

Commit 17e84a9

Browse files
authored
Merge pull request #11598 from dnicolodi/homebrew-scheme
Fixes #11539
2 parents ba0e3ac + f8beb61 commit 17e84a9

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

news/11598.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use the "venv" scheme if available to obtain prefixed lib paths.

src/pip/_internal/build_env.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
from pip import __file__ as pip_location
2020
from pip._internal.cli.spinners import open_spinner
21-
from pip._internal.locations import get_platlib, get_prefixed_libs, get_purelib
21+
from pip._internal.locations import (
22+
get_isolated_environment_lib_paths,
23+
get_platlib,
24+
get_purelib,
25+
)
2226
from pip._internal.metadata import get_default_environment, get_environment
2327
from pip._internal.utils.subprocess import call_subprocess
2428
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
@@ -37,7 +41,7 @@ def __init__(self, path: str) -> None:
3741
"nt" if os.name == "nt" else "posix_prefix",
3842
vars={"base": path, "platbase": path},
3943
)["scripts"]
40-
self.lib_dirs = get_prefixed_libs(path)
44+
self.lib_dirs = get_isolated_environment_lib_paths(path)
4145

4246

4347
def get_runnable_pip() -> str:

src/pip/_internal/locations/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"get_bin_user",
2828
"get_major_minor_version",
2929
"get_platlib",
30-
"get_prefixed_libs",
30+
"get_isolated_environment_lib_paths",
3131
"get_purelib",
3232
"get_scheme",
3333
"get_src_prefix",
@@ -482,13 +482,13 @@ def _looks_like_apple_library(path: str) -> bool:
482482
return path == f"/Library/Python/{get_major_minor_version()}/site-packages"
483483

484484

485-
def get_prefixed_libs(prefix: str) -> List[str]:
485+
def get_isolated_environment_lib_paths(prefix: str) -> List[str]:
486486
"""Return the lib locations under ``prefix``."""
487-
new_pure, new_plat = _sysconfig.get_prefixed_libs(prefix)
487+
new_pure, new_plat = _sysconfig.get_isolated_environment_lib_paths(prefix)
488488
if _USE_SYSCONFIG:
489489
return _deduplicated(new_pure, new_plat)
490490

491-
old_pure, old_plat = _distutils.get_prefixed_libs(prefix)
491+
old_pure, old_plat = _distutils.get_isolated_environment_lib_paths(prefix)
492492
old_lib_paths = _deduplicated(old_pure, old_plat)
493493

494494
# Apple's Python (shipped with Xcode and Command Line Tools) hard-code

src/pip/_internal/locations/_distutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_platlib() -> str:
173173
return get_python_lib(plat_specific=True)
174174

175175

176-
def get_prefixed_libs(prefix: str) -> Tuple[str, str]:
176+
def get_isolated_environment_lib_paths(prefix: str) -> Tuple[str, str]:
177177
return (
178178
get_python_lib(plat_specific=False, prefix=prefix),
179179
get_python_lib(plat_specific=True, prefix=prefix),

src/pip/_internal/locations/_sysconfig.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def get_platlib() -> str:
213213
return sysconfig.get_paths()["platlib"]
214214

215215

216-
def get_prefixed_libs(prefix: str) -> typing.Tuple[str, str]:
217-
paths = sysconfig.get_paths(vars={"base": prefix, "platbase": prefix})
216+
def get_isolated_environment_lib_paths(prefix: str) -> typing.Tuple[str, str]:
217+
vars = {"base": prefix, "platbase": prefix}
218+
if "venv" in sysconfig.get_scheme_names():
219+
paths = sysconfig.get_paths(vars=vars, scheme="venv")
220+
else:
221+
paths = sysconfig.get_paths(vars=vars)
218222
return (paths["purelib"], paths["platlib"])

0 commit comments

Comments
 (0)