Skip to content

Commit

Permalink
WIP: replace pep425tags with packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Mar 20, 2020
1 parent 6da376e commit 51cf960
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeqa-test-tag.yml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -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]
Expand Down
35 changes: 26 additions & 9 deletions src/wheel/bdist_wheel.py
Expand Up @@ -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
Expand All @@ -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


Expand All @@ -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('-', '_')

Expand Down Expand Up @@ -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"),
Expand All @@ -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. "
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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'
Expand All @@ -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,
Expand Down

0 comments on commit 51cf960

Please sign in to comment.