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

metadata version missmatch in uv 0.5.5 #9513

Open
franzhaas opened this issue Nov 28, 2024 · 14 comments
Open

metadata version missmatch in uv 0.5.5 #9513

franzhaas opened this issue Nov 28, 2024 · 14 comments
Labels
upstream An upstream dependency is involved

Comments

@franzhaas
Copy link

franzhaas commented Nov 28, 2024

Dear all,

I got this error when building and uploading my wheel with 0.5.5 to pypi.org.:

Upload failed with status code 400 Bad Request. Server says: 400 license-file introduced in metadata version 2.4, not 2.1. See https://packaging.python.org/specifications/core-metadata for more information.

But it does work for me with 0.5.4.

Accoridng to the release notes, with 0.5.5 uv started to use license-file, however I did not see a mention of moving the metadata version...

Any ideas?

Thanks in advance,
Franz

@konstin
Copy link
Member

konstin commented Nov 28, 2024

This is probably #9442: It's correct that you can only use license-file with metadata of at least version 2.4, but we were missing that field in the upload payload previously so pypi's validation didn't work. What build backend are you using?

@franzhaas
Copy link
Author

franzhaas commented Nov 28, 2024

Hi Konstin,

I use.:

[build-system]
requires = ["setuptools", "wheel", "setuptools-scm"]
build-backend = "setuptools.build_meta"

If it helps, the full project is located here.: https://github.com/MarketSquare/robotframework-construct

@FHU-yezi
Copy link

I got the same error with uv build used in building my project.

Here is the repo: https://github.com/FHU-yezi/sshared

The failed publish GitHub Action flow: https://github.com/FHU-yezi/sshared/actions/runs/12078435589/job/33682841905

It is a pure Python package and I got this error after updated to the latest uv version.

@konstin
Copy link
Member

konstin commented Nov 29, 2024

This is a bug in setuptools: pypa/setuptools#4759

uv unfortunately can't do anything about this.

@konstin konstin added the upstream An upstream dependency is involved label Nov 29, 2024
@franzhaas
Copy link
Author

franzhaas commented Nov 29, 2024 via email

@my1e5
Copy link
Contributor

my1e5 commented Nov 29, 2024

@franzhaas versioningit works with setuptools and also hatchling.

@franzhaas
Copy link
Author

I did not try to upload, but when building with hatchling, I ended up using metadata 2.3... for both uv 0.5.4 and 0.5.5...

this might be related to this one.:
pypa/hatch#1819

kbrgl added a commit to cartesia-ai/cartesia-python that referenced this issue Dec 2, 2024
@SermetPekin
Copy link

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

fixed my issue. as @kbrgl suggested

blast-hardcheese added a commit to replit/river-python that referenced this issue Dec 4, 2024
Why
===

Looks like setuptools has some issues with a new pypi restriction:
astral-sh/uv#9513. Hatchling does not have
these issues.

What changed
============

Switch to hatchling

Test plan
=========

Can we publish?
@senges
Copy link

senges commented Dec 5, 2024

If you still want to use setuptools as build backend, a simple workaround is to explicitly provide an empty value for licence-files in your pyproject.toml:

[tool.setuptools]
license-files = []

thomascellerier added a commit to thomascellerier/aiortnetlink that referenced this issue Dec 6, 2024
MatyiFKBT added a commit to MatyiFKBT/PySteamMarket that referenced this issue Dec 6, 2024
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Dec 7, 2024
Upload to PyPI failed with setuptools -
astral-sh/uv#9513
nijel added a commit to WeblateOrg/wllegal that referenced this issue Dec 16, 2024
nijel added a commit to WeblateOrg/language-data that referenced this issue Dec 16, 2024
nijel added a commit to WeblateOrg/weblate that referenced this issue Dec 16, 2024
Ensures we do not run into astral-sh/uv#9513
when publishing.
nijel added a commit to WeblateOrg/wllegal that referenced this issue Dec 16, 2024
It should be no longer used since introduction of pyproject.toml, but
apparently setuptools still parse it and that brings back issues like
astral-sh/uv#9513 which are fixed in pyproject.toml.
@hauntsaninja
Copy link
Contributor

hauntsaninja commented Dec 17, 2024

Okay, here's what I don't understand...
There is is a setuptools bug, but there's also something funky going on with uv.
I removed all mentions of license from my pyproject.toml and rm -rf build dist; uv build; uv publish gave me the same error. I then did rm -rf build dist; python -m build . ; python -m twine upload dist/* and everything works just fine. What gives?

Does uv build do any caching of metadata somewhere?

@FHU-yezi
Copy link

Okay, here's what I don't understand...
Maybe this is a setuptools bug, but there's something funky going on with uv.
I removed all mentions of license from my pyproject.toml and rm -rf build dist; uv build; uv publish gave me the same error. I then did rm -rf build dist; python -m build . ; python -m twine upload dist/* and everything works just fine. What gives?

Does uv build do any caching of metadata somewhere?

Use hatchling instead of setuptools should solve this problem, you can find guide about this in uv documentation.

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Dec 17, 2024

Thanks, I understand that's a valid workaround :-) Just based on the sequence of commands I ran, it appears there's also some issue in uv (maybe just a caching issue?) in addition to the one in setuptools

@konstin
Copy link
Member

konstin commented Dec 17, 2024

@hauntsaninja:

PEP 639 adds two new fields to the wheel metadata, License-Expression and License-File, with the corresponding pyproject.toml fields license = "..." and license-files = [...]. These fields are added in the new metadata version 2.4.

When uploading a wheel, the uploader reads the METADATA file from the wheel and transforms it to formdata. PyPI has recently started validating the two new metadata fields from PEP 639 in the formdata, thought PyPI does not validate the METADATA. Twine hasn't implemented that PEP yet (pypa/twine#1180), so it does not set the new license fields in the formdata, and PyPI does not catch the invalid metadata (declaring metadata version 2.1 while using version 2.4 fields).

@cdce8p
Copy link

cdce8p commented Dec 17, 2024

When uploading a wheel, the uploader reads the METADATA file from the wheel and transforms it to formdata. PyPI has recently started validating the two new metadata fields from PEP 639 in the formdata, thought PyPI does not validate the METADATA. Twine hasn't implemented that PEP yet (pypa/twine#1180), so it does not set the new license fields in the formdata, and PyPI does not catch the invalid metadata (declaring metadata version 2.1 while using version 2.4 fields).

The twine PR was just merged. It also added a carveout for setuptools to exclude License-File from the metadata if the version is <2.4 as to not break all projects which use setuptools. Maybe this is something which could be added to uv as well? https://github.com/pypa/twine/blob/main/twine/package.py#L225-L234

The setuptools behavior has been in place for so long at this point that it's probably not worth changing until PEP 639 is fully implemented. I've PRs open for that but those depend on some other work which need to happen first and will likely still need some time.

If you still want to use setuptools as build backend, a simple workaround is to explicitly provide an empty value for licence-files in your pyproject.toml:

[tool.setuptools]
license-files = []

Yes, this is a workaround. However, I'd advise against it. It will not only remove the License-File metadata but also the license files from the distribution. You can include them manually via MANIFEST.in but they will still be excluded from the wheel (unless placed inside the project package itself).

The ideal case would really be a workaround added to uv just like in twine.

akrabat added a commit to akrabat/rst2pdf that referenced this issue Dec 24, 2024
Set license-files to an empty array to work around issues releasing to
PyPI. See:

- astral-sh/uv#9513
- pypa/setuptools#4759
akrabat added a commit to akrabat/rst2pdf that referenced this issue Dec 24, 2024
Set license-files to an empty array to work around issues releasing to
PyPI. See:

- astral-sh/uv#9513
- pypa/setuptools#4759
StuartMacKay added a commit to StuartMacKay/ebird-checklists that referenced this issue Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream An upstream dependency is involved
Projects
None yet
Development

No branches or pull requests

8 participants