diff options
author | Nate Coraor <nate@bx.psu.edu> | 2015-09-03 12:32:00 -0400 |
---|---|---|
committer | Nate Coraor <nate@bx.psu.edu> | 2015-09-03 12:32:00 -0400 |
commit | 1ff8ee77f075fe2e60d99921a88912b25cd52ca1 (patch) | |
tree | a2e0963739700f998464e73b13891b877a0329c3 | |
parent | 9ae55eea1a70044e482190a46dae3aff568ad9d1 (diff) | |
download | wheel-1ff8ee77f075fe2e60d99921a88912b25cd52ca1.tar.gz |
SOABI support for Python 2.X and PyPy.
Additionally, fix the version portion of the Python tag on wheels built with
PyPy that use the Python API. It will now be the Python major version
concatenated with the PyPy major and minor versions.
Fixes issue #63 and issue #101.
-rw-r--r-- | wheel/bdist_wheel.py | 12 | ||||
-rw-r--r-- | wheel/pep425tags.py | 49 |
2 files changed, 42 insertions, 19 deletions
diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py index ac770e9..b8abaa0 100644 --- a/wheel/bdist_wheel.py +++ b/wheel/bdist_wheel.py @@ -33,7 +33,7 @@ from distutils.sysconfig import get_python_version from distutils import log as logger -from .pep425tags import get_abbr_impl, get_impl_ver +from .pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag from .util import native, open_for_csv from .archive import archive_wheelfile from .pkginfo import read_pkg_info, write_pkg_info @@ -143,14 +143,8 @@ class bdist_wheel(Command): plat_name = plat_name.replace('-', '_').replace('.', '_') impl_name = get_abbr_impl() impl_ver = get_impl_ver() - # PEP 3149 -- no SOABI in Py 2 - # For PyPy? - # "pp%s%s" % (sys.pypy_version_info.major, - # sys.pypy_version_info.minor) - abi_tag = sysconfig.get_config_vars().get('SOABI', 'none') - if abi_tag.startswith('cpython-'): - abi_tag = 'cp' + abi_tag.rsplit('-', 1)[-1] - + # PEP 3149 + abi_tag = str(get_abi_tag()).lower() tag = (impl_name + impl_ver, abi_tag, plat_name) # XXX switch to this alternate implementation for non-pure: assert tag == supported_tags[0] diff --git a/wheel/pep425tags.py b/wheel/pep425tags.py index a6220ea..b699d9f 100644 --- a/wheel/pep425tags.py +++ b/wheel/pep425tags.py @@ -26,11 +26,41 @@ def get_abbr_impl(): def get_impl_ver(): """Return implementation version.""" impl_ver = sysconfig.get_config_var("py_version_nodot") - if not impl_ver: - impl_ver = ''.join(map(str, sys.version_info[:2])) + if not impl_ver or get_abbr_impl() == 'pp': + impl_ver = ''.join(map(str, get_impl_version_info())) return impl_ver +def get_impl_version_info(): + """Return sys.version_info-like tuple for use in decrementing the minor + version.""" + if get_abbr_impl() == 'pp': + # as per https://github.com/pypa/pip/issues/2882 + return (sys.version_info[0], sys.pypy_version_info.major, + sys.pypy_version_info.minor) + else: + return sys.version_info[0], sys.version_info[1] + + +def get_abi_tag(): + """Return the ABI tag based on SOABI (if available) or emulate SOABI + (CPython 2, PyPy).""" + soabi = sysconfig.get_config_var('SOABI') + impl = get_abbr_impl() + if not soabi and impl in ('cp', 'pp'): + d = 'd' if hasattr(sys, 'pydebug') and sys.pydebug else '' + m = 'm' if impl == 'cp' else '' + u = 'u' if sys.maxunicode == 0x10ffff else '' + abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u) + elif soabi and soabi.startswith('cpython-'): + abi = 'cp' + soabi.split('-', 1)[-1] + elif soabi: + abi = soabi + else: + abi = None + return abi + + def get_platform(): """Return our platform name 'win32', 'linux_x86_64'""" # XXX remove distutils dependency @@ -49,18 +79,19 @@ def get_supported(versions=None): # Versions must be given with respect to the preference if versions is None: versions = [] - major = sys.version_info[0] + version_info = get_impl_version_info() + major = version_info[:-1] # Support all previous minor Python versions. - for minor in range(sys.version_info[1], -1, -1): - versions.append(''.join(map(str, (major, minor)))) + for minor in range(version_info[-1], -1, -1): + versions.append(''.join(map(str, major + (minor,)))) impl = get_abbr_impl() abis = [] - soabi = sysconfig.get_config_var('SOABI') - if soabi and soabi.startswith('cpython-'): - abis[0:0] = ['cp' + soabi.split('-', 1)[-1]] + abi = get_abi_tag() + if abi: + abis[0:0] = [abi] abi3s = set() import imp @@ -96,5 +127,3 @@ def get_supported(versions=None): supported.append(('py%s' % (version[0]), 'none', 'any')) return supported - - |