diff --git a/.github/workflows/codeqa-test-tag.yml b/.github/workflows/codeqa-test-tag.yml index da7e16c3..8c63fa3d 100644 --- a/.github/workflows/codeqa-test-tag.yml +++ b/.github/workflows/codeqa-test-tag.yml @@ -39,8 +39,8 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - - name: Upgrade setuptools - run: pip install "setuptools >= 40.9" + - name: Upgrade setuptools, pip + run: pip install "pip>=20.0.2" "setuptools >= 44" "packaging" - name: Install the project run: "pip install --no-binary=:all: ." - name: Install test dependencies diff --git a/setup.cfg b/setup.cfg index 1d718540..0fe6b779 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,6 +34,7 @@ package_dir= packages = find: python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* setup_requires = setuptools >= 40.9.0 +install_requires = packaging zip_safe = False [options.packages.find] diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index 5cece1f2..314854f3 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -11,6 +11,7 @@ import re from collections import OrderedDict from email.generator import Generator +import distutils from distutils.core import Command from distutils.sysconfig import get_python_version from distutils import log as logger @@ -19,13 +20,13 @@ from warnings import warn from zipfile import ZIP_DEFLATED, ZIP_STORED +import packaging.tags as tags +import platform import pkg_resources -from .pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform from .pkginfo import write_pkg_info from .metadata import pkginfo_to_metadata from .wheelfile import WheelFile -from . import pep425tags from . import __version__ as wheel_version @@ -35,6 +36,21 @@ PY_LIMITED_API_PATTERN = r'cp3\d' +def python_tag(): + return 'py{}'.format(sys.version_info[0]) + + +# copied from pep425tags.py, is there a better way? +def get_platform(): + """Return our platform name 'win32', 'linux_x86_64'""" + # XXX remove distutils dependency + result = distutils.util.get_platform().replace('.', '_').replace('-', '_') + if result == "linux_x86_64" and sys.maxsize == 2147483647: + # pip pull request #3497 + result = "linux_i686" + return result + + def safer_name(name): return safe_name(name).replace('-', '_') @@ -62,7 +78,7 @@ class bdist_wheel(Command): "temporary directory for creating the distribution"), ('plat-name=', 'p', "platform name to embed in generated filenames " - "(default: %s)" % get_platform(None)), + "(default: %s)" % get_platform()), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), @@ -88,7 +104,7 @@ class bdist_wheel(Command): .format(', '.join(supported_compressions))), ('python-tag=', None, "Python implementation compatibility tag" - " (default: py%s)" % get_impl_ver()[0]), + " (default: '%s')" % (python_tag())), ('build-number=', None, "Build number for this particular version. " "As specified in PEP-0427, this must start with a digit. " @@ -116,7 +132,7 @@ def initialize_options(self): self.group = None self.universal = False self.compression = 'deflated' - self.python_tag = 'py' + get_impl_ver()[0] + self.python_tag = python_tag() self.build_number = None self.py_limited_api = False self.plat_name_supplied = False @@ -167,6 +183,7 @@ def wheel_dist_name(self): return '-'.join(components) def get_tag(self): + from . import pep425tags # bdist sets self.plat_name if unset, we should only use it for purepy # wheels if the user supplied it. if self.plat_name_supplied: @@ -178,7 +195,7 @@ def get_tag(self): if self.plat_name and not self.plat_name.startswith("macosx"): plat_name = self.plat_name else: - plat_name = get_platform(self.bdist_dir) + plat_name = get_platform() if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647: plat_name = 'linux_i686' @@ -192,15 +209,15 @@ def get_tag(self): impl = self.python_tag tag = (impl, 'none', plat_name) else: - impl_name = get_abbr_impl() - impl_ver = get_impl_ver() + impl_name = pep425tags.get_abbr_impl() + impl_ver = pep425tags.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 abi_tag = 'abi3' else: - abi_tag = str(get_abi_tag()).lower() + abi_tag = str(pep425tags.get_abi_tag()).lower() tag = (impl, abi_tag, plat_name) supported_tags = pep425tags.get_supported( self.bdist_dir,