25
25
_AVAILABLE_SCHEMES = set (sysconfig .get_scheme_names ())
26
26
27
27
28
+ def _is_osx_framework () -> bool :
29
+ return sysconfig .get_config_var ("PYTHONFRAMEWORK" )
30
+
31
+
28
32
def _infer_prefix ():
29
33
# type: () -> str
30
34
"""Try to find a prefix scheme for the current platform.
31
35
32
36
This tries:
33
37
38
+ * A special ``osx_framework_library`` for Python distributed by Apple's
39
+ Command Line Tools, when not running in a virtual environment.
34
40
* Implementation + OS, used by PyPy on Windows (``pypy_nt``).
35
41
* Implementation without OS, used by PyPy on POSIX (``pypy``).
36
42
* OS + "prefix", used by CPython on POSIX (``posix_prefix``).
37
43
* Just the OS name, used by CPython on Windows (``nt``).
38
44
39
45
If none of the above works, fall back to ``posix_prefix``.
40
46
"""
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"
41
50
implementation_suffixed = f"{ sys .implementation .name } _{ os .name } "
42
51
if implementation_suffixed in _AVAILABLE_SCHEMES :
43
52
return implementation_suffixed
@@ -54,7 +63,7 @@ def _infer_prefix():
54
63
def _infer_user ():
55
64
# type: () -> str
56
65
"""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 ():
58
67
suffixed = "osx_framework_user"
59
68
else :
60
69
suffixed = f"{ os .name } _user"
0 commit comments