Skip to content

Commit 6ec1dd2

Browse files
committed
WIP: replace pep425tags with packaging
1 parent 6da376e commit 6ec1dd2

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

.github/workflows/codeqa-test-tag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
uses: actions/setup-python@v1
4040
with:
4141
python-version: ${{ matrix.python-version }}
42-
- name: Upgrade setuptools
43-
run: pip install "setuptools >= 40.9"
42+
- name: Upgrade setuptools, pip
43+
run: pip install "pip>=20.0.2" "setuptools >= 44" "packaging"
4444
- name: Install the project
4545
run: "pip install --no-binary=:all: ."
4646
- name: Install test dependencies

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ package_dir=
3434
packages = find:
3535
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
3636
setup_requires = setuptools >= 40.9.0
37+
install_requires = packaging
3738
zip_safe = False
3839

3940
[options.packages.find]

src/wheel/bdist_wheel.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import re
1212
from collections import OrderedDict
1313
from email.generator import Generator
14+
import distutils
1415
from distutils.core import Command
1516
from distutils.sysconfig import get_python_version
1617
from distutils import log as logger
@@ -21,11 +22,9 @@
2122

2223
import pkg_resources
2324

24-
from .pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform
2525
from .pkginfo import write_pkg_info
2626
from .metadata import pkginfo_to_metadata
2727
from .wheelfile import WheelFile
28-
from . import pep425tags
2928
from . import __version__ as wheel_version
3029

3130

@@ -35,6 +34,21 @@
3534
PY_LIMITED_API_PATTERN = r'cp3\d'
3635

3736

37+
def python_tag():
38+
return 'py{}'.format(sys.version_info[0])
39+
40+
41+
# copied from pep425tags.py, is there a better way?
42+
def get_platform():
43+
"""Return our platform name 'win32', 'linux_x86_64'"""
44+
# XXX remove distutils dependency
45+
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
46+
if result == "linux_x86_64" and sys.maxsize == 2147483647:
47+
# pip pull request #3497
48+
result = "linux_i686"
49+
return result
50+
51+
3852
def safer_name(name):
3953
return safe_name(name).replace('-', '_')
4054

@@ -62,7 +76,7 @@ class bdist_wheel(Command):
6276
"temporary directory for creating the distribution"),
6377
('plat-name=', 'p',
6478
"platform name to embed in generated filenames "
65-
"(default: %s)" % get_platform(None)),
79+
"(default: %s)" % get_platform()),
6680
('keep-temp', 'k',
6781
"keep the pseudo-installation tree around after " +
6882
"creating the distribution archive"),
@@ -88,7 +102,7 @@ class bdist_wheel(Command):
88102
.format(', '.join(supported_compressions))),
89103
('python-tag=', None,
90104
"Python implementation compatibility tag"
91-
" (default: py%s)" % get_impl_ver()[0]),
105+
" (default: '%s')" % (python_tag())),
92106
('build-number=', None,
93107
"Build number for this particular version. "
94108
"As specified in PEP-0427, this must start with a digit. "
@@ -116,7 +130,7 @@ def initialize_options(self):
116130
self.group = None
117131
self.universal = False
118132
self.compression = 'deflated'
119-
self.python_tag = 'py' + get_impl_ver()[0]
133+
self.python_tag = python_tag()
120134
self.build_number = None
121135
self.py_limited_api = False
122136
self.plat_name_supplied = False
@@ -167,6 +181,7 @@ def wheel_dist_name(self):
167181
return '-'.join(components)
168182

169183
def get_tag(self):
184+
from . import pep425tags
170185
# bdist sets self.plat_name if unset, we should only use it for purepy
171186
# wheels if the user supplied it.
172187
if self.plat_name_supplied:
@@ -178,7 +193,7 @@ def get_tag(self):
178193
if self.plat_name and not self.plat_name.startswith("macosx"):
179194
plat_name = self.plat_name
180195
else:
181-
plat_name = get_platform(self.bdist_dir)
196+
plat_name = get_platform()
182197

183198
if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647:
184199
plat_name = 'linux_i686'
@@ -192,15 +207,15 @@ def get_tag(self):
192207
impl = self.python_tag
193208
tag = (impl, 'none', plat_name)
194209
else:
195-
impl_name = get_abbr_impl()
196-
impl_ver = get_impl_ver()
210+
impl_name = pep425tags.get_abbr_impl()
211+
impl_ver = pep425tags.get_impl_ver()
197212
impl = impl_name + impl_ver
198213
# We don't work on CPython 3.1, 3.0.
199214
if self.py_limited_api and (impl_name + impl_ver).startswith('cp3'):
200215
impl = self.py_limited_api
201216
abi_tag = 'abi3'
202217
else:
203-
abi_tag = str(get_abi_tag()).lower()
218+
abi_tag = str(pep425tags.get_abi_tag()).lower()
204219
tag = (impl, abi_tag, plat_name)
205220
supported_tags = pep425tags.get_supported(
206221
self.bdist_dir,

0 commit comments

Comments
 (0)