提交 1ac90bbd 编写于 作者: S Sylvain 提交者: Tzu-ping Chung

Fix get_preferred_scheme detection for CPython 3.10 alpha

Co-authored-by: NSylvain Desodt <sylvain.desodt@faurecia.com>
Co-authored-by: NTzu-ping Chung <uranusjr@gmail.com>
上级 f7d912a2
Modify the ``sysconfig.get_preferred_scheme`` function check to be
compatible with CPython 3.10’s alphareleases.
......@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
_AVAILABLE_SCHEMES = set(sysconfig.get_scheme_names())
_HAS_PREFERRED_SCHEME_API = sys.version_info >= (3, 10)
_PREFERRED_SCHEME_API = getattr(sysconfig, "get_preferred_scheme", None)
def _infer_prefix() -> str:
......@@ -41,8 +41,8 @@ def _infer_prefix() -> str:
If none of the above works, fall back to ``posix_prefix``.
"""
if _HAS_PREFERRED_SCHEME_API:
return sysconfig.get_preferred_scheme("prefix") # type: ignore
if _PREFERRED_SCHEME_API:
return _PREFERRED_SCHEME_API("prefix")
os_framework_global = is_osx_framework() and not running_under_virtualenv()
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
return "osx_framework_library"
......@@ -61,8 +61,8 @@ def _infer_prefix() -> str:
def _infer_user() -> str:
"""Try to find a user scheme for the current platform."""
if _HAS_PREFERRED_SCHEME_API:
return sysconfig.get_preferred_scheme("user") # type: ignore
if _PREFERRED_SCHEME_API:
return _PREFERRED_SCHEME_API("user")
if is_osx_framework() and not running_under_virtualenv():
suffixed = "osx_framework_user"
else:
......@@ -76,8 +76,8 @@ def _infer_user() -> str:
def _infer_home() -> str:
"""Try to find a home for the current platform."""
if _HAS_PREFERRED_SCHEME_API:
return sysconfig.get_preferred_scheme("home") # type: ignore
if _PREFERRED_SCHEME_API:
return _PREFERRED_SCHEME_API("home")
suffixed = f"{os.name}_home"
if suffixed in _AVAILABLE_SCHEMES:
return suffixed
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册