Skip to content

Commit

Permalink
Use the "venv" scheme if available to obtain prefixed lib paths
Browse files Browse the repository at this point in the history
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 pypa#11539.
  • Loading branch information
dnicolodi committed Nov 16, 2022
1 parent 45debcc commit 19e8022
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/11598.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the "venv" scheme if available to obtain prefixed lib paths.
6 changes: 5 additions & 1 deletion src/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,9 @@ def get_platlib() -> str:


def get_prefixed_libs(prefix: str) -> typing.Tuple[str, str]:
paths = sysconfig.get_paths(vars={"base": prefix, "platbase": prefix})
vars = {"base": prefix, "platbase": prefix}
if "venv" in sysconfig.get_scheme_names():
paths = sysconfig.get_paths(vars=vars, scheme="venv")
else:
paths = sysconfig.get_paths(vars=vars)
return (paths["purelib"], paths["platlib"])

0 comments on commit 19e8022

Please sign in to comment.