Skip to content

Commit 11c4bcd

Browse files
committed
Special osx_framework_library prefix scheme
1 parent 991d0f4 commit 11c4bcd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

news/9844.bugfix.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Fix ``--user`` install scheme selection for macOS framework build.
1+
Fix warnings about install scheme selection for Python framework builds
2+
distributed by Apple's Command Line Tools.

src/pip/_internal/locations/_sysconfig.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,28 @@
2525
_AVAILABLE_SCHEMES = set(sysconfig.get_scheme_names())
2626

2727

28+
def _is_osx_framework() -> bool:
29+
return sysconfig.get_config_var("PYTHONFRAMEWORK")
30+
31+
2832
def _infer_prefix():
2933
# type: () -> str
3034
"""Try to find a prefix scheme for the current platform.
3135
3236
This tries:
3337
38+
* A special ``osx_framework_library`` for Python distributed by Apple's
39+
Command Line Tools, when not running in a virtual environment.
3440
* Implementation + OS, used by PyPy on Windows (``pypy_nt``).
3541
* Implementation without OS, used by PyPy on POSIX (``pypy``).
3642
* OS + "prefix", used by CPython on POSIX (``posix_prefix``).
3743
* Just the OS name, used by CPython on Windows (``nt``).
3844
3945
If none of the above works, fall back to ``posix_prefix``.
4046
"""
47+
os_framework_global = _is_osx_framework() and not running_under_virtualenv()
48+
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
49+
return "osx_framework_library"
4150
implementation_suffixed = f"{sys.implementation.name}_{os.name}"
4251
if implementation_suffixed in _AVAILABLE_SCHEMES:
4352
return implementation_suffixed
@@ -54,7 +63,7 @@ def _infer_prefix():
5463
def _infer_user():
5564
# type: () -> str
5665
"""Try to find a user scheme for the current platform."""
57-
if sysconfig.get_config_var("PYTHONFRAMEWORK"): # Mac framework build.
66+
if _is_osx_framework() and not running_under_virtualenv():
5867
suffixed = "osx_framework_user"
5968
else:
6069
suffixed = f"{os.name}_user"

0 commit comments

Comments
 (0)