Skip to content

12446 - better error msg for missing METADATA file #13402

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

eevelweezel
Copy link

Closes #12446

Adds a clear error message for when a package is skipped because the METADATA file is missing.

@@ -82,6 +82,8 @@ def get_dist_canonical_name(dist: importlib.metadata.Distribution) -> Normalized
return canonicalize_name(name)

name = cast(Any, dist).name
if name is None:
raise BadMetadata(dist, reason="missing `METADATA` file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't only get name equal to None when there's a missing METADATA file, we also get it when the .dist-info directory's name is incorrect - i.e., not in the form {name}-{version}.dist-info. There's also the possibility of a failure in get_info_location that isn't a missing METADATA file, as well as a .egg-info file with no stem (although that possibility seems very unlikely to me)

If we want to give a more informative message, we'll need to somehow distinguish the various possible failure cases in parse_name_and_version_from_info_directory.

METADATA file.
"""
# Create a .dist-info dir without METADATA file
dist_info_path = script.site_packages_path / "foo.dist-info"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an invalid .dist-info file - it should be something like foo-1.0.dist-info. The name you give will fail, not because of a missing METADATA file, but because the directory name format is wrong...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

METADATA file.
"""
# Create a .dist-info dir without METADATA file
dist_info_path = script.site_packages_path / "foo-1.0.dist-info"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug report shows a reproducer that is missing the version and I can't reproduce this EXCEPT with an invalid .dist-info name. I think the initial bug report is in error. I will comment on the ticket itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings for skipped <pkg>.dist-info are unclear when METADATA file is missing
2 participants