diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2017-07-29 23:23:05 +0300 |
|---|---|---|
| committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2017-07-29 23:23:05 +0300 |
| commit | f5e769886bc2e74ee4af730804e7148e5193ef42 (patch) | |
| tree | a7ad779f36f9eec54d76a3ab59475da13a11cc0d | |
| parent | c8e3fc27eab72eb3e17bb8880134e3e873a24598 (diff) | |
| download | wheel-git-f5e769886bc2e74ee4af730804e7148e5193ef42.tar.gz | |
Added support for specifying a build number
Signed-off-by: Alex Grönholm <alex.gronholm@nextday.fi>
| -rw-r--r-- | CHANGES.txt | 1 | ||||
| -rw-r--r-- | tests/test_tagopt.py | 11 | ||||
| -rw-r--r-- | wheel/bdist_wheel.py | 17 |
3 files changed, 27 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index f3f8eea..78e0312 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,7 @@ Stewart. - Convert absolute imports to relative. Thanks Ashish Bhate. - Fixed `>` being prepended to lines starting with "From" in the long description +- Added support for specifying a build number (as per PEP 427). Thanks Ian Cordasco. - Made the order of files in generated ZIP files deterministic. Thanks Matthias Bach. - Made the order of requirements in metadata deterministic. Thanks Chris Lamb. diff --git a/tests/test_tagopt.py b/tests/test_tagopt.py index 6d87b52..6eb8a87 100644 --- a/tests/test_tagopt.py +++ b/tests/test_tagopt.py @@ -48,6 +48,17 @@ def test_default_tag(temp_pkg): assert wheels[0].ext == '.whl' +def test_build_number(temp_pkg): + subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '--build-number=1'], + cwd=str(temp_pkg)) + dist_dir = temp_pkg.join('dist') + assert dist_dir.check(dir=1) + wheels = dist_dir.listdir() + assert len(wheels) == 1 + assert (wheels[0].basename == 'Test-1.0-1-py%s-none-any.whl' % (sys.version[0],)) + assert wheels[0].ext == '.whl' + + def test_explicit_tag(temp_pkg): subprocess.check_call( [sys.executable, 'setup.py', 'bdist_wheel', '--python-tag=py32'], diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py index dd67a8a..7511610 100644 --- a/wheel/bdist_wheel.py +++ b/wheel/bdist_wheel.py @@ -75,6 +75,10 @@ class bdist_wheel(Command): ('python-tag=', None, "Python implementation compatibility tag" " (default: py%s)" % get_impl_ver()[0]), + ('build-number=', None, + "Build number for this particular version. " + "As specified in PEP-0427, this must start with a digit. " + "[default: None]"), ('py-limited-api=', None, "Python tag (cp32|cp33|cpNN) for abi3 wheel tag" " (default: false)"), @@ -99,6 +103,7 @@ class bdist_wheel(Command): self.group = None self.universal = False self.python_tag = 'py' + get_impl_ver()[0] + self.build_number = None self.py_limited_api = False self.plat_name_supplied = False @@ -129,11 +134,17 @@ class bdist_wheel(Command): if val.lower() in ('1', 'true', 'yes'): self.universal = True + if self.build_number is not None and not self.build_number[:1].isdigit(): + raise ValueError("Build tag (build-number) must start with a digit.") + @property def wheel_dist_name(self): """Return distribution full name with - replaced with _""" - return '-'.join((safer_name(self.distribution.get_name()), - safer_version(self.distribution.get_version()))) + components = (safer_name(self.distribution.get_name()), + safer_version(self.distribution.get_version())) + if self.build_number: + components += (self.build_number,) + return '-'.join(components) def get_tag(self): # bdist sets self.plat_name if unset, we should only use it for purepy @@ -274,6 +285,8 @@ class bdist_wheel(Command): msg['Wheel-Version'] = '1.0' # of the spec msg['Generator'] = generator msg['Root-Is-Purelib'] = str(self.root_is_pure).lower() + if self.build_number is not None: + msg['Build'] = self.build_number # Doesn't work for bdist_wininst impl_tag, abi_tag, plat_tag = self.get_tag() |
