Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Release Notes

**UNRELEASED**

- Fixed ``wheel pack --build-number`` accepting build tags that are invalid in a
wheel file name (not starting with a digit, or containing ``-``), the same
validation ``wheel tags --build`` already performs
- Fixed the macOS platform-tag warning always using the plural "these files"
wording, even when only a single library required a higher deployment target
(`#697 <https://github.com/pypa/wheel/pull/697>`_)
Expand Down
4 changes: 3 additions & 1 deletion src/wheel/_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def parser() -> argparse.ArgumentParser:
help="Directory to store the wheel (default %(default)s)",
)
repack_parser.add_argument(
"--build-number", help="Build tag to use in the wheel name"
"--build-number",
type=parse_build_tag,
help="Build tag to use in the wheel name",
)
repack_parser.add_argument(
"--local-version", help="Local version identifier to add or replace"
Expand Down
31 changes: 31 additions & 0 deletions tests/commands/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from email.message import Message
from email.parser import BytesParser
from io import StringIO
from subprocess import CalledProcessError
from zipfile import Path, ZipFile

import pytest
Expand Down Expand Up @@ -224,3 +225,33 @@ def test_pack_local_version_rejects_invalid(

assert returncode == 1
assert "!invalid" in stderr.getvalue()


@pytest.mark.parametrize(
"build_tag, error",
[
pytest.param("foo", "build tag must begin with a digit", id="digitstart"),
pytest.param("1-f", "invalid character ('-') in build tag", id="hyphen"),
],
)
def test_pack_invalid_build_tag(
tmp_path_factory: TempPathFactory, tmp_path: Path, build_tag: str, error: str
) -> None:
unpack_dir = tmp_path_factory.mktemp("wheeldir")
with ZipFile(TESTWHEEL_PATH) as zf:
zf.extractall(unpack_dir)

with pytest.raises(CalledProcessError) as exc_info:
run_command(
"pack",
"--dest",
tmp_path,
unpack_dir,
"--build-number",
build_tag,
catch_systemexit=False,
)

exc = exc_info.value
assert exc.returncode == 2
assert f"error: argument --build-number: {error}" in exc.stderr
Loading