99from pip ._internal .models .scheme import SCHEME_KEYS , Scheme
1010from pip ._internal .utils .virtualenv import running_under_virtualenv
1111
12- from .base import get_major_minor_version
12+ from .base import get_major_minor_version , is_osx_framework
1313
1414logger = logging .getLogger (__name__ )
1515
@@ -30,13 +30,18 @@ def _infer_prefix() -> str:
3030
3131 This tries:
3232
33+ * A special ``osx_framework_library`` for Python distributed by Apple's
34+ Command Line Tools, when not running in a virtual environment.
3335 * Implementation + OS, used by PyPy on Windows (``pypy_nt``).
3436 * Implementation without OS, used by PyPy on POSIX (``pypy``).
3537 * OS + "prefix", used by CPython on POSIX (``posix_prefix``).
3638 * Just the OS name, used by CPython on Windows (``nt``).
3739
3840 If none of the above works, fall back to ``posix_prefix``.
3941 """
42+ os_framework_global = is_osx_framework () and not running_under_virtualenv ()
43+ if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES :
44+ return "osx_framework_library"
4045 implementation_suffixed = f"{ sys .implementation .name } _{ os .name } "
4146 if implementation_suffixed in _AVAILABLE_SCHEMES :
4247 return implementation_suffixed
@@ -52,7 +57,10 @@ def _infer_prefix() -> str:
5257
5358def _infer_user () -> str :
5459 """Try to find a user scheme for the current platform."""
55- suffixed = f"{ os .name } _user"
60+ if is_osx_framework () and not running_under_virtualenv ():
61+ suffixed = "osx_framework_user"
62+ else :
63+ suffixed = f"{ os .name } _user"
5664 if suffixed in _AVAILABLE_SCHEMES :
5765 return suffixed
5866 if "posix_user" not in _AVAILABLE_SCHEMES : # User scheme unavailable.
0 commit comments