From 53212d20ef9ad87420bf02abdd876e9c35560395 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 5 Feb 2016 11:38:24 -0500 Subject: Remove `--plat-tag` and restore `--plat-name` as the preferred/only way to modify the platform tag. But as with `--plat-tag`, it now overrides the tag on both pure python and extension wheels. --- CHANGES.txt | 7 +++---- wheel/bdist_wheel.py | 32 +++++++++++++++++--------------- wheel/test/test_tagopt.py | 21 +++++++++++---------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c4603d1..9ff2d5c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,8 @@ 0.27.0 ====== -- Rename `--plat-name` to `--plat-tag` (`--plat-name` remains as a deprecated - option) and support forcing a platform tag on pure-Python wheels, as well as - nonstandard platform tags on non-pure wheels (Pull Request #60, Issue #144, - thanks Andrés Díaz) +- Support forcing a platform tag using `--plat-name` on pure-Python wheels, as + well as nonstandard platform tags on non-pure wheels (Pull Request #60, Issue + #144, thanks Andrés Díaz) - Add SOABI tags to platform-specific wheels built for Python 2.X (Pull Request #55, Issue #63, Issue #101) - Support reproducible wheel files, wheels that can be rebuilt and will hash to diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py index 8920fce..90db748 100644 --- a/wheel/bdist_wheel.py +++ b/wheel/bdist_wheel.py @@ -52,12 +52,9 @@ class bdist_wheel(Command): user_options = [('bdist-dir=', 'b', "temporary directory for creating the distribution"), - ('plat-tag=', 'p', - "platform tag to embed in generated filenames " + ('plat-name=', 'p', + "platform name to embed in generated filenames " "(default: %s)" % get_platform()), - ('plat-name=', None, - "DEPRECATED. Platform tag to embed in generated " - "filenames (default: %s)" % get_platform()), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), @@ -101,6 +98,7 @@ class bdist_wheel(Command): self.group = None self.universal = False self.python_tag = 'py' + get_impl_ver()[0] + self.plat_name_supplied = False def finalize_options(self): if self.bdist_dir is None: @@ -108,6 +106,7 @@ class bdist_wheel(Command): self.bdist_dir = os.path.join(bdist_base, 'wheel') self.data_dir = self.wheel_dist_name + '.data' + self.plat_name_supplied = self.plat_name is not None need_options = ('dist_dir', 'plat_name', 'skip_build') @@ -132,27 +131,30 @@ class bdist_wheel(Command): safer_version(self.distribution.get_version()))) def get_tag(self): - plat_tag = self.plat_tag or self.plat_name - if plat_tag: - plat_tag = plat_tag.replace('-', '_').replace('.', '_') - supported_tags = pep425tags.get_supported(supplied_platform=plat_tag) + # 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: + plat_name = self.plat_name + elif self.root_is_pure: + plat_name = 'any' + else: + plat_name = self.plat_name or get_platform() + plat_name = plat_name.replace('-', '_').replace('.', '_') if self.root_is_pure: if self.universal: impl = 'py2.py3' else: impl = self.python_tag - if not plat_tag: - plat_tag = 'any' - tag = (impl, 'none', plat_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() - if not plat_tag: - plat_tag = get_platform().replace('-', '_').replace('.', '_') - tag = (impl_name + impl_ver, abi_tag, plat_tag) + 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] return tag diff --git a/wheel/test/test_tagopt.py b/wheel/test/test_tagopt.py index a8de089..b0d083e 100644 --- a/wheel/test/test_tagopt.py +++ b/wheel/test/test_tagopt.py @@ -1,5 +1,6 @@ """ -Tests for the bdist_wheel tag options (--python-tag and --universal) +Tests for the bdist_wheel tag options (--python-tag, --universal, and +--plat-name) """ import sys @@ -50,7 +51,7 @@ def test_default_tag(temp_pkg): assert dist_dir.check(dir=1) wheels = dist_dir.listdir() assert len(wheels) == 1 - assert wheels[0].basename.startswith('Test-1.0-py%s-' % (sys.version[0],)) + assert wheels[0].basename == 'Test-1.0-py%s-none-any.whl' % (sys.version[0],) assert wheels[0].ext == '.whl' def test_explicit_tag(temp_pkg): @@ -122,9 +123,9 @@ def test_legacy_wheel_section_in_setup_cfg(temp_pkg): assert wheels[0].basename.startswith('Test-1.0-py2.py3-') assert wheels[0].ext == '.whl' -def test_plat_tag_purepy(temp_pkg): +def test_plat_name_purepy(temp_pkg): subprocess.check_call( - [sys.executable, 'setup.py', 'bdist_wheel', '--plat-tag=testplat.pure'], + [sys.executable, 'setup.py', 'bdist_wheel', '--plat-name=testplat.pure'], cwd=str(temp_pkg)) dist_dir = temp_pkg.join('dist') assert dist_dir.check(dir=1) @@ -133,10 +134,10 @@ def test_plat_tag_purepy(temp_pkg): assert wheels[0].basename.endswith('-testplat_pure.whl') assert wheels[0].ext == '.whl' -def test_plat_tag_ext(temp_ext_pkg): +def test_plat_name_ext(temp_ext_pkg): try: subprocess.check_call( - [sys.executable, 'setup.py', 'bdist_wheel', '--plat-tag=testplat.arch'], + [sys.executable, 'setup.py', 'bdist_wheel', '--plat-name=testplat.arch'], cwd=str(temp_ext_pkg)) except subprocess.CalledProcessError: pytest.skip("Cannot compile C Extensions") @@ -147,8 +148,8 @@ def test_plat_tag_ext(temp_ext_pkg): assert wheels[0].basename.endswith('-testplat_arch.whl') assert wheels[0].ext == '.whl' -def test_plat_tag_purepy_in_setupcfg(temp_pkg): - temp_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_tag=testplat.pure') +def test_plat_name_purepy_in_setupcfg(temp_pkg): + temp_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.pure') subprocess.check_call( [sys.executable, 'setup.py', 'bdist_wheel'], cwd=str(temp_pkg)) @@ -159,8 +160,8 @@ def test_plat_tag_purepy_in_setupcfg(temp_pkg): assert wheels[0].basename.endswith('-testplat_pure.whl') assert wheels[0].ext == '.whl' -def test_plat_tag_ext_in_setupcfg(temp_ext_pkg): - temp_ext_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_tag=testplat.arch') +def test_plat_name_ext_in_setupcfg(temp_ext_pkg): + temp_ext_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.arch') try: subprocess.check_call( [sys.executable, 'setup.py', 'bdist_wheel'], -- cgit v1.2.1