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