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

Can't run a twine upload due to version problem #15611

Closed
luriol opened this issue Mar 16, 2024 · 11 comments
Closed

Can't run a twine upload due to version problem #15611

luriol opened this issue Mar 16, 2024 · 11 comments
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue

Comments

@luriol
Copy link

luriol commented Mar 16, 2024

I'm trying to upload a distrubtion of a package to pypy using python3 -m twine upload dist/.16

I get an error saying
"
InvalidDistribution: Metadata is missing required fields: Name, Version.
"
If I unpack the whl file and look at the METADATA file I notice that an exact older version which uploaded correctly had the line

Metadata-Version: 2.1

When I currently try to build the package it won't upload (and also fails a twine check). When I look at the METADATA from the newer version is says

Metadata-Version: 2.3

If I simply change 2.3 to 2.1 I can rezip the whl package and it now passes the twine check and everything is fine.

How can I fix this?

@luriol luriol added bug 🐛 requires triaging maintainers need to do initial inspection of issue labels Mar 16, 2024
@di
Copy link
Member

di commented Mar 17, 2024

Hi, are you using the latest version of twine?

@stecohen
Copy link

stecohen commented Mar 17, 2024

I have the same issue - updating to the latest version of twine (5.0.0) did not help

@di
Copy link
Member

di commented Mar 17, 2024

Are you using the latest version of twine?

@stecohen
Copy link

Yes, as per my initial post

@stecohen
Copy link

I had to downgrade python from 3.11.7 to 3.10.10 to fix this issue

@umarbutler
Copy link

umarbutler commented Mar 18, 2024

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:

@LightOfHeaven1994
Copy link

@umarbutler thanks a lot, bumping pkginfo helped us to resolve the issue ❤️

@luriol luriol closed this as completed Mar 18, 2024
@LtStarbuck1030
Copy link

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:

* [Check command doesn't recognize metadata 2.3 pypa/twine#1059](https://github.com/pypa/twine/issues/1059)

* [Can't run a twine upload due to version problem #15611](https://github.com/pypi/warehouse/issues/15611)

* [Twine should require pkginfo > 1.10 pypa/twine#1070](https://github.com/pypa/twine/issues/1070)

* [Successfully build *.whl and *.tar.gz, but cannot upload them through twine pypa/packaging-problems#735](https://github.com/pypa/packaging-problems/issues/735)

This worked perfectly. Ashamed of how long it took me to stumble on this response. Thank you <3

@pultarmi
Copy link

pultarmi commented Jun 29, 2024

This is still a problem with twine==5.1.1, pkginfo==1.11.1, hatchling==1.25.0, python=3.12.4 on Ubuntu 24. I tried multiple versions of the packages and Python, it's always the same error message

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.

There is Metadata-Version: 2.3 isnide PKG_INFO in dist folder, so I guess that hatchling uses a newer metadata format than what twine supports.

As I see it, the only working workaround is to modify the header in PKG_INFO manually.

@dmitrycrivoy
Copy link

This is still a problem with twine==5.1.1, pkginfo==1.11.1, hatchling==1.25.0, python=3.12.4 on Ubuntu 24. I tried multiple versions of the packages and Python, it's always the same error message

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.

There is Metadata-Version: 2.3 isnide PKG_INFO in dist folder, so I guess that hatchling uses a newer metadata format than what twine supports.

As I see it, the only working workaround is to modify the header in PKG_INFO manually.

Interesting thing.
I upgraded twine up to 5.1.1, then I tried to upgrade pkginfo up to latest version (currently 1.11.1) and got an error twine 5.1.1 requires pkginfo<1.11, but you have pkginfo 1.11.1 which is incompatible., so I run this command and it worked:
python3.11 -m pip install --upgrade pkginfo==1.10

Make sure to use your specific python version if it's applicable to you.

@progeroffline
Copy link

After update package pkginfo the problem went away.

python3 -m pip install --upgrade pkginfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue
Projects
None yet
Development

No branches or pull requests

9 participants