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

InvalidDistribution: Metadata is missing required fields: Name, Version. #1446

Open
impredicative opened this issue Dec 16, 2024 · 3 comments

Comments

@impredicative
Copy link

Steps to Reproduce

I am unable to publish to PyPI. This was working fine for me with an older version of rye. For what it's worth, here is my pyproject.toml.

Expected Result

Obviously I should be able to publish to PyPI.

Actual Result

I get the error:

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.                              
error: failed to publish files

I do have name and version defined in my pyproject.toml (see Steps).

Version Info

rye 0.43.0
commit: unknown (d67cac134 2024-12-09)
platform: linux (aarch64)
self-python: [email protected]
symlink support: true
uv enabled: true

Stacktrace

No response

@PushUpek
Copy link
Contributor

I am experiencing the same issue.

Hatch (starting from version 1.27) builds packages with the new Metadata-Version: 2.4.

In the PKG-INFO file, the metadata includes:

Metadata-Version: 2.4

However, Rye uses twine==5.1.1, which does not support Metadata-Version 2.4.

If you update your pyproject.toml to the following:

[build-system]
requires = ["hatchling==1.26.3", "hatch-vcs"]
build-backend = "hatchling.build"

you should be able to build and publish the package successfully.

@impredicative
Copy link
Author

impredicative commented Dec 16, 2024

That's an effective workaround. To recap, essentially, in my pyproject.toml, I applied the following diff:

 [build-system]
-requires = ["hatchling"]
+requires = ["hatchling==1.26.3"]  # Without a version spec, hatchling==1.27.0 is used which fails to publish. Ref: https://github.com/astral-sh/rye/issues/1446#issuecomment-2545154562

As for hatch-vcs, I didn't need to list it.

I will leave this issue open for the rye maintainers to still fix as the current solution is just a workaround.

@sswatson
Copy link

I had the same problem, and this solution worked for me too.

I believe this problem could be fixed by bumping the version of twine in bootstrap.rs again, but pinning the twine version used by Rye internally while leaving the hatchling version in the user project unrestricted seems like it's going to be an ongoing footgun.

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

No branches or pull requests

3 participants