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

Requires-Dist metadata not canonicalized between wheels and sdists #4336

Closed
wimglenn opened this issue Apr 30, 2024 · 4 comments
Closed

Requires-Dist metadata not canonicalized between wheels and sdists #4336

wimglenn opened this issue Apr 30, 2024 · 4 comments
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@wimglenn
Copy link
Contributor

wimglenn commented Apr 30, 2024

setuptools version

setuptools==69.5.1 wheel==0.43.0

Python version

3.12

OS

macOS/Linux

Description

Requirements are normalized differently in sdist PKG-INFO file and wheel METADATA file

Expected behavior

Metadata in sdist and wheel are same

How to Reproduce

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

[project]
name = "example-proj"
version = "0.1"

[project.optional-dependencies]
all = ["typing-extensions >=4.2,   <5 ; python_version  <'3.8'"]

Using build I get an sdist and wheel that are mostly identical (sans trailing newline) but the Requires-Dist: values are formatted differently.

Output

After extraction, the wheel metadata looks like this

$ cat example_proj-0.1.dist-info/METADATA
Metadata-Version: 2.1
Name: example-proj
Version: 0.1
Provides-Extra: all
Requires-Dist: typing-extensions <5,>=4.2 ; (python_version < "3.8") and extra == 'all'

The sdist metadata looks like this

$ cat example_proj-0.1/PKG-INFO              
Metadata-Version: 2.1
Name: example-proj
Version: 0.1
Provides-Extra: all
Requires-Dist: typing-extensions<5,>=4.2; python_version < "3.8" and extra == "all"

Although the meaning is the same, it would be nice if metadata files in wheel and sdist were byte-for-byte identical.

For the record, the sdist's content seems to be in agreement with the way packaging wants:

>>> from packaging.requirements import Requirement
>>> print(Requirement("typing-extensions >=4.2,   <5 ; (python_version  <'3.8')   and extra == 'all'"))
typing-extensions<5,>=4.2; python_version < "3.8" and extra == "all"

I'm not sure if the best place to address the issue is in setuptools directly or in pypa/wheel.

@wimglenn wimglenn added bug Needs Triage Issues that need to be evaluated for severity and status. labels Apr 30, 2024
@wimglenn wimglenn changed the title [BUG] Requires-Dist metadata not canonicalized between wheels and sdists Apr 30, 2024
@wimglenn
Copy link
Contributor Author

pypa/wheel#395 similar issue on the wheel repo

wimglenn added a commit to wimglenn/wheel that referenced this issue Apr 30, 2024
This makes the METADATA file from bdist_wheel and the PKG-INFO file from setuptools render the same way (see pypa/setuptools#4336 for more info)

Closes pypa#395
@abravalheri
Copy link
Contributor

I think handling this in wheel is the way to go. If I am not mistaken we already use packaging for "canonicalising" the requirements in the setuptools code base.

agronholm pushed a commit to pypa/wheel that referenced this issue May 1, 2024
This makes the METADATA file from bdist_wheel and the PKG-INFO file from setuptools render the same way (see pypa/setuptools#4336 for more info).

Closes #395.
@wimglenn
Copy link
Contributor Author

wimglenn commented May 1, 2024

@abravalheri I've handled it in wheel. I'm now curious, though, why doesn't setuptools vendor wheel as it does with the other packages it wants to use?

@abravalheri
Copy link
Contributor

I would say it is a work in progress 😅

It is slightly more complicated than usual because the integration happens at entry-point level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

No branches or pull requests

2 participants