Skip to content

Commit 418771a

Browse files
committed
Use the "venv" scheme if available to obtain prefixed lib paths
get_prefixed_libs() computes the Python path for libraries in a pip isolation environment. Python 3.11 introduced the "venv" path scheme to be used in these cases. Use it if available. This solves a bug on Homebrew's Python 3.10 and later where the default paths scheme when Python is invoked outside a virtual environment is "osx_framework_library" and does not relative to the "{base}" or "{platbase}" variables. Fixes #11539.
1 parent 9aa422d commit 418771a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

news/11598.bugfix.rst

+1
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/locations/_sysconfig.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,9 @@ def get_platlib() -> str:
214214

215215

216216
def get_prefixed_libs(prefix: str) -> typing.Tuple[str, str]:
217-
paths = sysconfig.get_paths(vars={"base": prefix, "platbase": prefix})
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)