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