diff --git a/news/13634.bugfix.rst b/news/13634.bugfix.rst new file mode 100644 index 00000000000..8df20c49d05 --- /dev/null +++ b/news/13634.bugfix.rst @@ -0,0 +1 @@ +Patch scheme to posix_prefix if posix_local and --prefix is specified diff --git a/src/pip/_internal/locations/_sysconfig.py b/src/pip/_internal/locations/_sysconfig.py index d4a448ece52..f44058bda89 100644 --- a/src/pip/_internal/locations/_sysconfig.py +++ b/src/pip/_internal/locations/_sysconfig.py @@ -155,6 +155,12 @@ def get_scheme( else: scheme_name = _infer_prefix() + # Special case: When installing into a custom prefix, use posix_prefix + # instead of posix_local because it should be used only to redirecting + # to /usr/local. + if prefix is not None and scheme_name == "posix_local": + scheme_name = "posix_prefix" + # Special case: When installing into a custom prefix, use posix_prefix # instead of osx_framework_library. See _should_use_osx_framework_prefix() # docstring for details.