Skip to content

Commit

Permalink
Special osx_framework_library prefix scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Apr 26, 2021
1 parent 991d0f4 commit dfc4603
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,28 @@
_AVAILABLE_SCHEMES = set(sysconfig.get_scheme_names())


def _is_osx_framework() -> bool:
return sysconfig.get_config_var("PYTHONFRAMEWORK")


def _infer_prefix():
# type: () -> str
"""Try to find a prefix scheme for the current platform.
This tries:
* A special ``osx_framework_library`` for Python distributed by Apple's
Command Line Tools, when not running in a virtual environment.
* Implementation + OS, used by PyPy on Windows (``pypy_nt``).
* Implementation without OS, used by PyPy on POSIX (``pypy``).
* OS + "prefix", used by CPython on POSIX (``posix_prefix``).
* Just the OS name, used by CPython on Windows (``nt``).
If none of the above works, fall back to ``posix_prefix``.
"""
os_framework_global = _is_osx_framework() and not running_under_virtualenv()
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
return "osx_framework_library"
implementation_suffixed = f"{sys.implementation.name}_{os.name}"
if implementation_suffixed in _AVAILABLE_SCHEMES:
return implementation_suffixed
Expand All @@ -54,7 +63,7 @@ def _infer_prefix():
def _infer_user():
# type: () -> str
"""Try to find a user scheme for the current platform."""
if sysconfig.get_config_var("PYTHONFRAMEWORK"): # Mac framework build.
if _is_osx_framework() and not running_under_virtualenv():
suffixed = "osx_framework_user"
else:
suffixed = f"{os.name}_user"
Expand Down

0 comments on commit dfc4603

Please sign in to comment.