Skip to content

Commit fb9fe50

Browse files
authored
Merge pull request #1106 from pypa/bug/1100
Indicate which files failed to find metadata info
2 parents 527f6d4 + 77c1634 commit fb9fe50

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tests/test_wheel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def test_read_wheel_empty_metadata(tmpdir):
9696

9797
with pytest.raises(
9898
exceptions.InvalidDistribution,
99-
match=re.escape(f"No METADATA in archive: {whl_file}"),
99+
match=re.escape(
100+
f"No METADATA in archive or METADATA missing 'Metadata-Version': {whl_file}"
101+
),
100102
):
101103
wheel.Wheel(whl_file)

twine/wheel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,21 @@ def read_file(name: str) -> bytes:
7373
"Not a known archive format for file: %s" % fqn
7474
)
7575

76+
searched_files: List[str] = []
7677
try:
7778
for path in self.find_candidate_metadata_files(names):
7879
candidate = "/".join(path)
7980
data = read_file(candidate)
8081
if b"Metadata-Version" in data:
8182
return data
83+
searched_files.append(candidate)
8284
finally:
8385
archive.close()
8486

85-
raise exceptions.InvalidDistribution("No METADATA in archive: %s" % fqn)
87+
raise exceptions.InvalidDistribution(
88+
"No METADATA in archive or METADATA missing 'Metadata-Version': "
89+
"%s (searched %s)" % (fqn, ",".join(searched_files))
90+
)
8691

8792
def parse(self, data: bytes) -> None:
8893
super().parse(data)

0 commit comments

Comments
 (0)