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 · 18 comments
Closed

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

luriol opened this issue Mar 16, 2024 · 18 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

wjones127 pushed a commit to lancedb/lancedb that referenced this issue Dec 2, 2024
@BrainAnnex
Copy link

BrainAnnex commented Dec 18, 2024

SHORT VERSION : updating twine does NOT resolve the problem. Fortunately, updating pkginfo to the latest 1.12.0 fixes everything :)


I slammed against this same issue today. I did everything IDENTICALLY to my usual protocol that had worked just fine until 1 month ago, to generate the distribution package, namely running python3 -m build (in the top directory of my project),
which created the usual tar.gz and py3-none-any.whl files.

So far so good - but then attempting to run python3 -m twine upload dist/* (which always worked before) suddenly started barking:

'''
Uploading distributions to https://upload.pypi.org/legacy/
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, 2.3. `
'''
Very puzzling, before I hadn't changed anything in the OS (a Linux Mint 21.2 laptop dedicated to PyPI uploads).

When I double-clicked on the tar.gz and py3-none-any.whl files, drilling down until I found PKG-INFO files, and opened them, I saw Metadata-Version: 2.4 .
By contrast, to my astonishment, I saw Metadata-Version: 2.3 in the old files that I still had around from last month!
I have no idea how this happened!! A test of re-generating those files from an old release project ALSO resulted in Metadata-Version 2.4, unlike in the previous seemingly-identical run a month before. Puzzled! Maybe a clue is that the output of running the build command is now slightly different from what used to be,

At any rate, I found out which version of twine I had: twine --version showed 5.1.1
The twine software is a local install, as showed by which twine (which gave a /.local/bin directory)... and so I updated it, to the current latest version 6.0.1 by means of : python3 -m pip install --upgrade twine

As others on this thread have pointed out, the problem did NOT go away by upgrading twine.

As suggested on this thread, I then investigated pkginfo : I had version 1.10.0 installed locally. I upgraded it to the latest 1.12.0 with:

python3 -m pip install --upgrade pkginfo

and, MIRACLE, twine (which is now version 6.0.1) works :)

PS: puzzled by the word "legacy" in Uploading distributions to https://upload.pypi.org/legacy/ , but that seem a benign quirk...

@jhcole
Copy link

jhcole commented Jan 23, 2025

Found this thread working through the error in #15611 (comment)

After updating Twine to 6.1.0, and pkginfo to 1.12.0 (latest at time of writing) I get this error.

ERROR    InvalidDistribution: Invalid distribution metadata: unrecognized or malformed field 'license-file'

Downgrading Twine to 6.0.1 worked.

@di
Copy link
Member

di commented Jan 23, 2025

@jhcole Is it possible your metadata is actually malformed? Can you show us what you're trying to build or provide the distribution you're trying to upload?

@ariebovenberg
Copy link

@di I ran into the same issue. Downgrading to twine==6.0.1 fixed it. I'm not sure if it's malformed—I'm not that familiar with the format. It's generated by maturin. Here is the METADATA:

Metadata-Version: 2.4
Name: whenever
Version: 0.6.17
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python
Classifier: Programming Language :: Rust
Classifier: Typing :: Typed
Requires-Dist: tzdata >=2020.1 ; sys_platform == 'win32'
License-File: LICENSE
License-File: LICENSE-THIRD-PARTY
Summary: Modern datetime library for Python
Keywords: datetime,typesafe,rust,date,time,timezone,utc,aware,zoneinfo,tzdata,tzdb
Author-email: Arie Bovenberg <[email protected]>
Maintainer-email: Arie Bovenberg <[email protected]>
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://whenever.readthedocs.io
Project-URL: Repository, https://github.com/ariebovenberg/whenever
Project-URL: Issues, https://github.com/ariebovenberg/whenever/issues
Project-URL: Changelog, https://github.com/ariebovenberg/whenever/blob/master/CHANGELOG.rst

[readme omitted for brevity]

@di
Copy link
Member

di commented Jan 31, 2025

@jhcole @ariebovenberg Looks like this is pypa/twine#1216

@pacman82
Copy link

Can confirm, have the same symptom for the build of https://github.com/pacman82/arrow-odbc-py, stumbled on this thread debugging CI. Downgrading to twine 6.0.1 helped me also, but I still do not know what's going on here.

Best, Markus

@attack68
Copy link

Same issue. Also using Maturin. Just downgraded to 6.0.1

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