Skip to content

Commit

Permalink
Fixed wrong wheel file names in converted pure-Python eggs/wininsts
Browse files Browse the repository at this point in the history
Fixes #644.
  • Loading branch information
agronholm committed Nov 23, 2024
1 parent d78f0e3 commit d343391
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

**UNRELEASED**

- Fixed pure Python wheels converted from eggs and wininst files having the ABI tag in
the file name

**0.45.0 (2024-11-08)**

- Refactored the ``convert`` command to not need setuptools to be installed
Expand Down
3 changes: 1 addition & 2 deletions src/wheel/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def __init__(self, path: Path):
self.version = match.group("ver")
if pyver := match.group("pyver"):
self.pyver = pyver.replace(".", "")
self.abi = self.pyver.replace("py", "cp")
if arch := match.group("arch"):
self.abi = self.pyver.replace("py", "cp")
self.platform = normalize(arch)

self.metadata = Message()
Expand Down Expand Up @@ -225,7 +225,6 @@ def __init__(self, path: Path):
self.platform = normalize(match.group("platform"))
if pyver := match.group("pyver"):
self.pyver = pyver.replace(".", "")
self.abi = pyver.replace("py", "cp")

# Look for an .egg-info directory and any .pyd files for more precise info
egg_info_found = pyd_found = False
Expand Down
17 changes: 17 additions & 0 deletions tests/cli/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ def egg_path(arch: str, pyver: str | None, tmp_path: Path) -> str:
return str(bdist_path)


@pytest.fixture
def expected_wheel_filename(pyver: str | None, arch: str) -> str:
if arch != "any":
pyver = pyver.replace(".", "") if pyver else "py2.py3"
abiver = pyver.replace("py", "cp")
return f"sampledist-1.0.0-{pyver}-{abiver}-{arch}.whl"
else:
return "sampledist-1.0.0-py2.py3-none-any.whl"


def test_egg_re() -> None:
"""Make sure egg_info_re matches."""
egg_names_path = os.path.join(os.path.dirname(__file__), "eggnames.txt")
Expand All @@ -191,10 +201,12 @@ def test_convert_egg_file(
tmp_path: Path,
arch: str,
expected_wheelfile: bytes,
expected_wheel_filename: str,
capsys: CaptureFixture,
) -> None:
convert([egg_path], str(tmp_path), verbose=True)
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
assert wheel_path.name == expected_wheel_filename
with WheelFile(wheel_path) as wf:
assert wf.read("sampledist-1.0.0.dist-info/METADATA") == EXPECTED_METADATA
assert wf.read("sampledist-1.0.0.dist-info/WHEEL") == expected_wheelfile
Expand All @@ -207,8 +219,10 @@ def test_convert_egg_directory(
egg_path: str,
tmp_path: Path,
tmp_path_factory: TempPathFactory,
pyver: str | None,
arch: str,
expected_wheelfile: bytes,
expected_wheel_filename: str,
capsys: CaptureFixture,
) -> None:
with zipfile.ZipFile(egg_path) as egg_file:
Expand All @@ -218,6 +232,7 @@ def test_convert_egg_directory(

convert([str(egg_dir_path)], str(tmp_path), verbose=True)
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
assert wheel_path.name == expected_wheel_filename
with WheelFile(wheel_path) as wf:
assert wf.read("sampledist-1.0.0.dist-info/METADATA") == EXPECTED_METADATA
assert wf.read("sampledist-1.0.0.dist-info/WHEEL") == expected_wheelfile
Expand All @@ -231,10 +246,12 @@ def test_convert_bdist_wininst(
tmp_path: Path,
arch: str,
expected_wheelfile: bytes,
expected_wheel_filename: str,
capsys: CaptureFixture,
) -> None:
convert([bdist_wininst_path], str(tmp_path), verbose=True)
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
assert wheel_path.name == expected_wheel_filename
with WheelFile(wheel_path) as wf:
assert (
wf.read("sampledist-1.0.0.data/scripts/somecommand")
Expand Down

0 comments on commit d343391

Please sign in to comment.