Skip to content

Commit 77810bc

Browse files
committed
Special osx_framework_library prefix scheme
1 parent 1501272 commit 77810bc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

news/9844.bugfix.rst

Lines changed: 2 additions & 1 deletion
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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,27 @@
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() -> str:
2933
"""Try to find a prefix scheme for the current platform.
3034
3135
This tries:
3236
37+
* A special ``osx_framework_library`` for Python distributed by Apple's
38+
Command Line Tools, when not running in a virtual environment.
3339
* Implementation + OS, used by PyPy on Windows (``pypy_nt``).
3440
* Implementation without OS, used by PyPy on POSIX (``pypy``).
3541
* OS + "prefix", used by CPython on POSIX (``posix_prefix``).
3642
* Just the OS name, used by CPython on Windows (``nt``).
3743
3844
If none of the above works, fall back to ``posix_prefix``.
3945
"""
46+
os_framework_global = _is_osx_framework() and not running_under_virtualenv()
47+
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
48+
return "osx_framework_library"
4049
implementation_suffixed = f"{sys.implementation.name}_{os.name}"
4150
if implementation_suffixed in _AVAILABLE_SCHEMES:
4251
return implementation_suffixed
@@ -52,7 +61,7 @@ def _infer_prefix() -> str:
5261

5362
def _infer_user() -> str:
5463
"""Try to find a user scheme for the current platform."""
55-
if sysconfig.get_config_var("PYTHONFRAMEWORK"): # Mac framework build.
64+
if _is_osx_framework() and not running_under_virtualenv():
5665
suffixed = "osx_framework_user"
5766
else:
5867
suffixed = f"{os.name}_user"

0 commit comments

Comments
 (0)