24
24
25
25
_AVAILABLE_SCHEMES = set (sysconfig .get_scheme_names ())
26
26
27
+ _HAS_PREFERRED_SCHEME_API = sys .version_info >= (3 , 10 )
28
+
27
29
28
30
def _infer_prefix () -> str :
29
31
"""Try to find a prefix scheme for the current platform.
@@ -39,6 +41,8 @@ def _infer_prefix() -> str:
39
41
40
42
If none of the above works, fall back to ``posix_prefix``.
41
43
"""
44
+ if _HAS_PREFERRED_SCHEME_API :
45
+ return sysconfig .get_preferred_scheme ("prefix" )
42
46
os_framework_global = is_osx_framework () and not running_under_virtualenv ()
43
47
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES :
44
48
return "osx_framework_library"
@@ -57,6 +61,8 @@ def _infer_prefix() -> str:
57
61
58
62
def _infer_user () -> str :
59
63
"""Try to find a user scheme for the current platform."""
64
+ if _HAS_PREFERRED_SCHEME_API :
65
+ return sysconfig .get_preferred_scheme ("user" )
60
66
if is_osx_framework () and not running_under_virtualenv ():
61
67
suffixed = "osx_framework_user"
62
68
else :
@@ -70,6 +76,8 @@ def _infer_user() -> str:
70
76
71
77
def _infer_home () -> str :
72
78
"""Try to find a home for the current platform."""
79
+ if _HAS_PREFERRED_SCHEME_API :
80
+ return sysconfig .get_preferred_scheme ("home" )
73
81
suffixed = f"{ os .name } _home"
74
82
if suffixed in _AVAILABLE_SCHEMES :
75
83
return suffixed
0 commit comments