Skip to content

Commit d343391

Browse files
committed
Fixed wrong wheel file names in converted pure-Python eggs/wininsts
Fixes #644.
1 parent d78f0e3 commit d343391

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

docs/news.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release Notes
22
=============
33

4+
**UNRELEASED**
5+
6+
- Fixed pure Python wheels converted from eggs and wininst files having the ABI tag in
7+
the file name
8+
49
**0.45.0 (2024-11-08)**
510

611
- Refactored the ``convert`` command to not need setuptools to be installed

src/wheel/cli/convert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def __init__(self, path: Path):
122122
self.version = match.group("ver")
123123
if pyver := match.group("pyver"):
124124
self.pyver = pyver.replace(".", "")
125-
self.abi = self.pyver.replace("py", "cp")
126125
if arch := match.group("arch"):
126+
self.abi = self.pyver.replace("py", "cp")
127127
self.platform = normalize(arch)
128128

129129
self.metadata = Message()
@@ -225,7 +225,6 @@ def __init__(self, path: Path):
225225
self.platform = normalize(match.group("platform"))
226226
if pyver := match.group("pyver"):
227227
self.pyver = pyver.replace(".", "")
228-
self.abi = pyver.replace("py", "cp")
229228

230229
# Look for an .egg-info directory and any .pyd files for more precise info
231230
egg_info_found = pyd_found = False

tests/cli/test_convert.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ def egg_path(arch: str, pyver: str | None, tmp_path: Path) -> str:
176176
return str(bdist_path)
177177

178178

179+
@pytest.fixture
180+
def expected_wheel_filename(pyver: str | None, arch: str) -> str:
181+
if arch != "any":
182+
pyver = pyver.replace(".", "") if pyver else "py2.py3"
183+
abiver = pyver.replace("py", "cp")
184+
return f"sampledist-1.0.0-{pyver}-{abiver}-{arch}.whl"
185+
else:
186+
return "sampledist-1.0.0-py2.py3-none-any.whl"
187+
188+
179189
def test_egg_re() -> None:
180190
"""Make sure egg_info_re matches."""
181191
egg_names_path = os.path.join(os.path.dirname(__file__), "eggnames.txt")
@@ -191,10 +201,12 @@ def test_convert_egg_file(
191201
tmp_path: Path,
192202
arch: str,
193203
expected_wheelfile: bytes,
204+
expected_wheel_filename: str,
194205
capsys: CaptureFixture,
195206
) -> None:
196207
convert([egg_path], str(tmp_path), verbose=True)
197208
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
209+
assert wheel_path.name == expected_wheel_filename
198210
with WheelFile(wheel_path) as wf:
199211
assert wf.read("sampledist-1.0.0.dist-info/METADATA") == EXPECTED_METADATA
200212
assert wf.read("sampledist-1.0.0.dist-info/WHEEL") == expected_wheelfile
@@ -207,8 +219,10 @@ def test_convert_egg_directory(
207219
egg_path: str,
208220
tmp_path: Path,
209221
tmp_path_factory: TempPathFactory,
222+
pyver: str | None,
210223
arch: str,
211224
expected_wheelfile: bytes,
225+
expected_wheel_filename: str,
212226
capsys: CaptureFixture,
213227
) -> None:
214228
with zipfile.ZipFile(egg_path) as egg_file:
@@ -218,6 +232,7 @@ def test_convert_egg_directory(
218232

219233
convert([str(egg_dir_path)], str(tmp_path), verbose=True)
220234
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
235+
assert wheel_path.name == expected_wheel_filename
221236
with WheelFile(wheel_path) as wf:
222237
assert wf.read("sampledist-1.0.0.dist-info/METADATA") == EXPECTED_METADATA
223238
assert wf.read("sampledist-1.0.0.dist-info/WHEEL") == expected_wheelfile
@@ -231,10 +246,12 @@ def test_convert_bdist_wininst(
231246
tmp_path: Path,
232247
arch: str,
233248
expected_wheelfile: bytes,
249+
expected_wheel_filename: str,
234250
capsys: CaptureFixture,
235251
) -> None:
236252
convert([bdist_wininst_path], str(tmp_path), verbose=True)
237253
wheel_path = next(path for path in tmp_path.iterdir() if path.suffix == ".whl")
254+
assert wheel_path.name == expected_wheel_filename
238255
with WheelFile(wheel_path) as wf:
239256
assert (
240257
wf.read("sampledist-1.0.0.data/scripts/somecommand")

0 commit comments

Comments
 (0)