1
"""Generate and work with PEP 425 Compatibility Tags."""
8
except ImportError: # pragma nocover
10
import distutils.sysconfig as sysconfig
15
"""Return abbreviated implementation name."""
16
if hasattr(sys, 'pypy_version_info'):
18
elif sys.platform.startswith('java'):
20
elif sys.platform == 'cli':
28
"""Return implementation version."""
29
return ''.join(map(str, sys.version_info[:2]))
33
"""Return our platform name 'win32', 'linux_x86_64'"""
34
# XXX remove distutils dependency
35
return distutils.util.get_platform().replace('.', '_').replace('-', '_')
38
def get_supported(versions=None, noarch=False):
39
"""Return a list of supported tags for each version specified in
42
:param versions: a list of string versions, of the form ["33", "32"],
43
or None. The first version will be assumed to support our ABI.
47
# Versions must be given with respect to the preference
50
major = sys.version_info[0]
51
# Support all previous minor Python versions.
52
for minor in range(sys.version_info[1], -1, -1):
53
versions.append(''.join(map(str, (major, minor))))
55
impl = get_abbr_impl()
60
soabi = sysconfig.get_config_var('SOABI')
61
except IOError as e: # Issue #1074
62
warnings.warn("{0}".format(e), RuntimeWarning)
65
if soabi and soabi.startswith('cpython-'):
66
abis[0:0] = ['cp' + soabi.split('-', 1)[-1]]
70
for suffix in imp.get_suffixes():
71
if suffix[0].startswith('.abi'):
72
abi3s.add(suffix[0].split('.', 2)[1])
74
abis.extend(sorted(list(abi3s)))
81
# Current version, current API (built specifically for our Python):
83
supported.append(('%s%s' % (impl, versions[0]), abi, arch))
85
# No abi / arch, but requires our implementation:
86
for i, version in enumerate(versions):
87
supported.append(('%s%s' % (impl, version), 'none', 'any'))
89
# Tagged specifically as being cross-version compatible
90
# (with just the major version specified)
91
supported.append(('%s%s' % (impl, versions[0][0]), 'none', 'any'))
93
# No abi / arch, generic Python
94
for i, version in enumerate(versions):
95
supported.append(('py%s' % (version,), 'none', 'any'))
97
supported.append(('py%s' % (version[0]), 'none', 'any'))
101
supported_tags = get_supported()
102
supported_tags_noarch = get_supported(noarch=True)