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

Successfully build *.whl and *.tar.gz, but cannot upload them through twine #735

Closed
huskier opened this issue Mar 17, 2024 · 20 comments
Closed

Comments

@huskier
Copy link

huskier commented Mar 17, 2024

Problem description

I've successfully build the *.whl and *.tar.gz file with command "python -m build".

Successfully built minimalcadquery-0.0.1.tar.gz and minimalcadquery-0.0.1-py3-none-any.whl

However, when I use the following command to upload them,
python -m twine upload --repository testpypi dist/*
I have encountered and error, which states:

Uploading distributions to https://test.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.

I think that I do give the name and version in my TOML file.
[project]
name = "MinimalCadQuery"
version = "0.0.1"

What's wrong here in my application case?

My directory structure looks like this:
D:\CAD\MINIMALCADQUERY
├─dist
└─src
└─minimalcadquery
├─contrib
├─occ_impl
│ ├─exporters
│ └─importers
└─plugins

@sinoroc
Copy link

sinoroc commented Mar 17, 2024

What is the build backend? Is there a build-system table in pyproject.toml?

Are there more files in the dist directory than these two distributions you mentioned?

@huskier
Copy link
Author

huskier commented Mar 17, 2024

Thank you sinoroc for your reply. @sinoroc

Here is the content of the whole pyproject.toml. There is only those two files abovementioned.

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "minimalcadquery"
version = "0.0.1"
authors = [
{ name="huskier", email="huskier@x.com" },
]
description = "A minimal cadquery package"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

@jeanas
Copy link

jeanas commented Mar 17, 2024

What you're trying to upload is the result of running python -m build or hatch build, right? Or did you generate the .tar.gz yourself?

@pfmoore
Copy link
Member

pfmoore commented Mar 17, 2024

Do you have the latest version of twine?

The relevant twine issue (now closed as fixed): pypa/twine#1059

@huskier
Copy link
Author

huskier commented Mar 17, 2024

What you're trying to upload is the result of running python -m build or hatch build, right? Or did you generate the .tar.gz yourself?

Yes, I generate the *.tar.gz myself with python -m build. I am following the tutorial of packaging python projects.

@huskier
Copy link
Author

huskier commented Mar 17, 2024

Do you have the latest version of twine?

The relevant twine issue (now closed as fixed): pypa/twine#1059

I've just upgrade to the latest twine-5.0.0, and the issue is still there.

I could successfully upload the package in the tutorial (https://packaging.python.org/en/latest/tutorials/packaging-projects/).

For the problem one, I just want to upload my real project.

@henryiii
Copy link
Contributor

Could you try hatchling>=1.22.2 in your build-system.requires? Both 1.22.0 and 1.22.1 had a (quickly fixed) bug when making metadata 2.3 when building from an SDist, which is what build does. Those releases have been yanked, but maybe you’re getting an old version from pip’s cache? (I think there’s also a pip purge command that will clear the cache)

@echarles
Copy link

Could you try hatchling>=1.22.2

Same issue here, although i have tried with hatchling>=1.22.2

@henryiii
Copy link
Contributor

henryiii commented Mar 17, 2024

Ahh, what version of pkginfo you have? If you upgraded twine you might still have an old pkginfo that doesn’t support 2.3. (This is why I always use pipx run twine)

@echarles
Copy link

Ahh, what version of pkginfo you have?

pkginfo 1.9.6

I am unblocked pinning hatchling to 1.21.1. Inspecting the failing tar.gz, I have seen the generated Metadata-Version was 2.3., so higher than 2.2. With hatchling to 1.21, the hatchling the Metadata-Version is back to 2.2.

twine 5.0 was not helpful to upload.

@henryiii
Copy link
Contributor

That’s what happened. Pkginfo 1.10 is required by twine to support metadata 2.3. When you pip upgrade, dependent packages are not upgraded by default.

https://pypi.org/project/pkginfo/

@huskier
Copy link
Author

huskier commented Mar 17, 2024

@henryiii Yes, upgrading pkginfo solved the uploading issue.

pip install pkginfo==1.10.0

Thank you, henryiii. @henryiii Thank you all of you!

@echarles Maybe you could try to upgrade pkginfo to version 1.10.0.

@echarles
Copy link

That’s what happened. Pkginfo 1.10 is required by twine to support metadata 2.3.

Thx for the confirmation 👍

When you pip upgrade, dependent packages are not upgraded by default.

Does twine 5 requires Pkginfo 1.10 ?

PS: probably the pip system should upgrade automatically. or refuse to install... ?

@pfmoore
Copy link
Member

pfmoore commented Mar 17, 2024

Does twine 5 requires Pkginfo 1.10 ?

No, it doesn't. Which is arguably a bug in twine. I reported it as pypa/twine#1070, we'll see what the twine maintainers think.

@henryiii
Copy link
Contributor

It does not require it, unless you need metadata 2.3 support. That’s why it’s not upgraded unless you tell Pip upgrade dependencies too.

Twine is an application, so it really should be installed using pipx. pipx reinstall twine would then fix it. Or pipx run twine will download and run it in one command, redownloading it if it’s more than a week old. (That’s what I do)

@pfmoore
Copy link
Member

pfmoore commented Mar 17, 2024

Twine is an application, so it really should be installed using pipx.

That's a fair point (and I'd be fine if the twine issue I raised was closed with that explanation). Would pipx grade twine upgrade the dependencies? If not (and I think it doesn't), that's still a rather annoying behaviour, although I don't know at that point which of pip, pipx, or twine should be responsible for it...

@henryiii
Copy link
Contributor

I believe no, but I’d like to see if that can be changed. know pipx upgrade nox[uv] will not upgrade dependencies specified by uv, at least.

(I use reinstall instead of upgrade due to it getting a clean up to date environment when I’m not using run)

@mibur1
Copy link

mibur1 commented Mar 18, 2024

I had the same issue, pip install pkginfo==1.10.0 solved it as well.

@umarbutler
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:

@di
Copy link
Sponsor Member

di commented Mar 18, 2024

Closing in favor of pypa/twine#1070, the fix for this is to upgrade to pkginfo>=1.10.0.

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

10 participants