Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_supported():
return list(wheel.pep425tags.get_supported()) + [('py3', 'none', 'win32')]
from wheel.install import WheelFile
from wheel.pep425tags import get_supported
WHEELPAT = "%(name)s-%(ver)s-%(pyver)s-%(abi)s-%(arch)s.whl"
def make_wheel(name, ver, pyver, abi, arch):
name = WHEELPAT % {'name': name, 'ver': ver, 'pyver': pyver, 'abi': abi, 'arch': arch}
return WheelFile(name)
# This relies on the fact that generate_supported will always return the
# exact pyver, abi, and architecture for its first (best) match.
sup = get_supported()
pyver, abi, arch = sup[0]
genver = 'py' + pyver[2:]
majver = genver[:3]
COMBINATIONS = (
('bar', '0.9', 'py2.py3', 'none', 'any'),
('bar', '0.9', majver, 'none', 'any'),
('bar', '0.9', genver, 'none', 'any'),
('bar', '0.9', pyver, abi, arch),
('bar', '1.3.2', majver, 'none', 'any'),
('bar', '3.1', genver, 'none', 'any'),
('bar', '3.1', pyver, abi, arch),
('foo', '1.0', majver, 'none', 'any'),
('foo', '1.1', pyver, abi, arch),
('foo', '2.1', majver + '0', 'none', 'any'),
# This will not be compatible for Python x.0. Beware when we hit Python
plat_name = plat_name.replace('-', '_').replace('.', '_')
if self.root_is_pure:
if self.universal:
impl = 'py2.py3'
else:
impl = self.python_tag
tag = (impl, 'none', plat_name)
else:
impl_name = get_abbr_impl()
impl_ver = get_impl_ver()
# PEP 3149
abi_tag = str(get_abi_tag()).lower()
tag = (impl_name + impl_ver, abi_tag, plat_name)
supported_tags = pep425tags.get_supported(
supplied_platform=plat_name if self.plat_name_supplied else None)
# XXX switch to this alternate implementation for non-pure:
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
return tag
if self.py_limited_api and (impl_name + impl_ver).startswith('cp3'):
impl = self.py_limited_api
abi_tag = "abi3" if sys.platform != "win32" else "none"
else:
abi_tag = str(get_abi_tag()).lower()
tag = (impl, abi_tag, plat_name)
try:
supported_tags = pep425tags.get_supported(
supplied_platform=plat_name if self.plat_name_supplied else None)
except TypeError:
# This was breaking the CI, specifically the:
# OpenSUSE 15 x86_64 using ICC
# Some versions of Python 2.7 require an argument called
# 'archive_root' which doesn't exist on 3, so we set it to
# 'None' for those version (e.g.: Python 2.7.14)
supported_tags = pep425tags.get_supported(None,
supplied_platform=plat_name if self.plat_name_supplied else None)
# XXX switch to this alternate implementation for non-pure:
if (self.py_limited_api) or (plat_name in ('manylinux1_x86_64') and sys.version_info[0] == 2):
return tag
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
assert tag in supported_tags, ("would build wheel with unsupported tag {}".format(tag))
return tag
def __init__(self,
filename,
fp=None,
append=False,
context=get_supported):
"""
:param fp: A seekable file-like object or None to open(filename).
:param append: Open archive in append mode.
:param context: Function returning list of supported tags. Wheels
must have the same context to be sortable.
"""
self.filename = filename
self.fp = fp
self.append = append
self.context = context
basename = os.path.basename(filename)
self.parsed_filename = WHEEL_INFO_RE(basename)
if not basename.endswith('.whl') or self.parsed_filename is None:
raise BadWheelFile("Bad filename '%s'" % filename)
tag = (impl, 'none', plat_name)
else:
impl_name = get_abbr_impl()
impl_ver = get_impl_ver()
impl = impl_name + impl_ver
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and (impl_name + impl_ver).startswith('cp3'):
impl = self.py_limited_api
if sys.platform == "win32":
abi_tag = 'none'
else:
abi_tag = 'abi3'
else:
abi_tag = str(get_abi_tag()).lower()
tag = (impl, abi_tag, plat_name)
supported_tags = pep425tags.get_supported(
supplied_platform=plat_name if self.plat_name_supplied else None)
# XXX switch to this alternate implementation for
# non-pure:
if not self.py_limited_api:
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
assert tag in supported_tags, \
"would build wheel with unsupported tag {}".format(tag)
return tag