diff options
author | Nate Coraor <nate@bx.psu.edu> | 2015-11-10 14:26:23 -0500 |
---|---|---|
committer | Nate Coraor <nate@bx.psu.edu> | 2015-11-10 14:26:23 -0500 |
commit | 2c52729ccaf837c8c41696b38e7bf2fc9fd3267c (patch) | |
tree | b9babbaf197b16ab4e1794f56d0a919062db109f | |
parent | 7e06215ea42efcce8e550a8ac8a17fc45c06d39f (diff) | |
download | wheel-2c52729ccaf837c8c41696b38e7bf2fc9fd3267c.tar.gz |
Incorporate changes to Python 2 ABI detection from the pip version.
-rw-r--r-- | wheel/pep425tags.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/wheel/pep425tags.py b/wheel/pep425tags.py index 5bf7c0f..2fe8510 100644 --- a/wheel/pep425tags.py +++ b/wheel/pep425tags.py @@ -1,6 +1,7 @@ """Generate and work with PEP 425 Compatibility Tags.""" import sys +import warnings try: import sysconfig @@ -50,15 +51,42 @@ def get_impl_version_info(): return sys.version_info[0], sys.version_info[1] +def get_flag(var, fallback, expected=True, warn=True): + """Use a fallback method for determining SOABI flags if the needed config + var is unset or unavailable.""" + val = get_config_var(var) + if val is None: + if warn: + warnings.warn("Config variable '{0}' is unset, Python ABI tag may " + "be incorrect".format(var), RuntimeWarning, 2) + return fallback() + return val == expected + + def get_abi_tag(): """Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).""" soabi = get_config_var('SOABI') impl = get_abbr_impl() - if not soabi and impl in ('cp', 'pp'): - d = 'd' if get_config_var('Py_DEBUG') else '' - m = 'm' if get_config_var('WITH_PYMALLOC') else '' - u = 'u' if sys.maxunicode == 0x10ffff else '' + if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'): + d = '' + m = '' + u = '' + if get_flag('Py_DEBUG', + lambda: hasattr(sys, 'gettotalrefcount'), + warn=(impl == 'cp')): + d = 'd' + if get_flag('WITH_PYMALLOC', + lambda: impl == 'cp', + warn=(impl == 'cp')): + m = 'm' + if get_flag('Py_UNICODE_SIZE', + lambda: sys.maxunicode == 0x10ffff, + expected=4, + warn=(impl == 'cp' and + sys.version_info < (3, 3))) \ + and sys.version_info < (3, 3): + u = 'u' abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u) elif soabi and soabi.startswith('cpython-'): abi = 'cp' + soabi.split('-')[1] |