Skip to content

Commit

Permalink
Merge pull request #1106 from pypa/bug/1100
Browse files Browse the repository at this point in the history
Indicate which files failed to find metadata info
  • Loading branch information
sigmavirus24 committed May 12, 2024
2 parents 527f6d4 + 77c1634 commit fb9fe50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def test_read_wheel_empty_metadata(tmpdir):

with pytest.raises(
exceptions.InvalidDistribution,
match=re.escape(f"No METADATA in archive: {whl_file}"),
match=re.escape(
f"No METADATA in archive or METADATA missing 'Metadata-Version': {whl_file}"
),
):
wheel.Wheel(whl_file)
7 changes: 6 additions & 1 deletion twine/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,21 @@ def read_file(name: str) -> bytes:
"Not a known archive format for file: %s" % fqn
)

searched_files: List[str] = []
try:
for path in self.find_candidate_metadata_files(names):
candidate = "/".join(path)
data = read_file(candidate)
if b"Metadata-Version" in data:
return data
searched_files.append(candidate)
finally:
archive.close()

raise exceptions.InvalidDistribution("No METADATA in archive: %s" % fqn)
raise exceptions.InvalidDistribution(
"No METADATA in archive or METADATA missing 'Metadata-Version': "
"%s (searched %s)" % (fqn, ",".join(searched_files))
)

def parse(self, data: bytes) -> None:
super().parse(data)
Expand Down

0 comments on commit fb9fe50

Please sign in to comment.