twine icon indicating copy to clipboard operation
twine copied to clipboard

Check command doesn't recognize metadata 2.3

Open konstin opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] 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 (https://github.com/pypi/warehouse/pull/13606). I've added support for this in maturin (https://github.com/PyO3/maturin/pull/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

konstin avatar Feb 27 '24 10:02 konstin

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

sigmavirus24 avatar Feb 27 '24 12:02 sigmavirus24

pkginfo release is out which appears to have support

alex avatar Mar 04 '24 12:03 alex

@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.

sigmavirus24 avatar Mar 04 '24 15:03 sigmavirus24

Thanks, confirmed that this works.

konstin avatar Mar 04 '24 16:03 konstin

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

henryiii avatar Mar 17 '24 13:03 henryiii

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)}."
            )

sigmavirus24 avatar Mar 17 '24 14:03 sigmavirus24

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

henryiii avatar Mar 17 '24 17:03 henryiii

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 mention that upgrading pkginfo will probably solve the issue.

Related issues I have located are as follows:

  • https://github.com/pypa/twine/issues/1059
  • https://github.com/pypi/warehouse/issues/15611
  • https://github.com/pypa/twine/issues/1070
  • https://github.com/pypa/packaging-problems/issues/735

umarbutler avatar Mar 18 '24 11:03 umarbutler