pypa / twine

Utilities for interacting with PyPI

Home Page:https://twine.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check command doesn't recognize metadata 2.3

konstin opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues (open and closed), and could not find an existing issue

What keywords did you use to search existing issues?

2.3
Metadata

Please describe why your using this option

Pypi now supports uploading wheels with metadata 2.3 (pypi/warehouse#13606). I've added support for this in maturin (PyO3/maturin#1965) and successfully uploaded the wheel (METADATA in the pypi inspector), but twine check doesn't recognize metadata 2.3 yet:

$ twine check --strict test-crates/pyo3-mixed/target/wheels/pyo3_mixed-2.1.5-cp311-cp311-manylinux_2_34_x86_64.whl 
Checking test-crates/pyo3-mixed/target/wheels/pyo3_mixed-2.1.5-cp311-cp311-manylinux_2_34_x86_64.whl: ERROR    InvalidDistribution: Metadata is missing required fields: Name, Version.                                        
         Make sure the distribution includes the files where those fields are specified, and is using a supported        
         Metadata-Version: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2.   

Anything else you'd like to mention?

No response

This isn't working as we rely on pkginfo which doesn't appear to have this support https://bazaar.launchpad.net/~tseaver/pkginfo/trunk/view/head:/pkginfo/distribution.py https://bazaar.launchpad.net/~tseaver/pkginfo/trunk/revision/221

I'll see if I can get that added

pkginfo release is out which appears to have support

@konstin a re-install will fix this for you as it should grab the new pkginfo since we don't cap that package at all.

Thanks, confirmed that this works.

Does this still not mention 2.3 in the error message, even though 2.3 is now supported?

Does this still not mention 2.3 in the error message, even though 2.3 is now supported?

I'm not sure what you're asking but if it's about the error posted above, that's generated by us from pkginfo https://github.com/pypa/twine/blob/main/twine%2Fpackage.py#L116-L123

            supported_metadata = list(pkginfo.distribution.HEADER_ATTRS)
            raise exceptions.InvalidDistribution(
                "Metadata is missing required fields: "
                f"{', '.join(missing_fields)}.\n"
                "Make sure the distribution includes the files where those fields "
                "are specified, and is using a supported Metadata-Version: "
                f"{', '.join(supported_metadata)}."
            )

Ahh, perfect, the bug was that pkginfo wasn’t updated.

On 15 March, I updated a package using py -m twine upload --repository pypi dist/* and experienced no issues. Today, I built a new package, seemingly having not upgraded any of my build tools (although perhaps it is possible I did?) and experienced this issue: InvalidDistribution: Metadata is missing required fields: Name, Version.. This persisted even after upgrading my twine and trying Python 11 instead of 12. Only after upgrading pkginfo was the issue fixed. A higher version of pkginfo should be a requirement to ensure that this doesn't happen to others. At the very least, twine's error message should mentioned that upgrading pkginfo will probably solve the issue.

Related issues I have located are as follows: