Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate which files failed to find metadata info #1106

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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