Skip to content

Commit 05c65ab

Browse files
authored
Merge pull request #1088 from jlarkin09/AIPCC-14568
fix(finders): filter find_wheel glob to .whl files only
2 parents ae65fdb + 8def63a commit 05c65ab

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/fromager/finders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def find_wheel(
138138
# comparison.
139139
for base in candidate_bases:
140140
logger.debug('looking for wheel as "%s"', base)
141-
for filename in downloads_dir.glob("*"):
141+
for filename in downloads_dir.glob("*.whl"):
142142
if str(filename.name).lower().startswith(base.lower()):
143143
return filename
144144

tests/test_finders.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,31 @@ def test_find_wheel(
5858
assert str(wheel) == str(actual)
5959

6060

61+
def test_find_wheel_ignores_non_wheel_files(tmp_path: pathlib.Path) -> None:
62+
downloads = tmp_path / "downloads"
63+
downloads.mkdir()
64+
wheel = downloads / "mypkg-1.2-py3-none-any.whl"
65+
wheel.write_text("not-empty")
66+
(downloads / "mypkg-1.2-py3-none-any.tar.gz").write_text("not-a-wheel")
67+
(downloads / "mypkg-1.2.metadata").write_text("not-a-wheel")
68+
69+
req = Requirement("mypkg")
70+
actual = finders.find_wheel(downloads, req, "1.2", ())
71+
assert str(wheel) == str(actual)
72+
73+
74+
def test_find_wheel_returns_none_when_only_non_wheel_files(
75+
tmp_path: pathlib.Path,
76+
) -> None:
77+
downloads = tmp_path / "downloads"
78+
downloads.mkdir()
79+
(downloads / "mypkg-1.2-py3-none-any.tar.gz").write_text("not-a-wheel")
80+
(downloads / "mypkg-1.2.metadata").write_text("not-a-wheel")
81+
82+
req = Requirement("mypkg")
83+
assert finders.find_wheel(downloads, req, "1.2", ()) is None
84+
85+
6186
@pytest.mark.parametrize(
6287
"dist_name,version_string,unpack_base,source_base",
6388
[

0 commit comments

Comments
 (0)