Skip to content

Commit

Permalink
Use vendored packaging to canonicalize requirements
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wimglenn committed Apr 30, 2024
1 parent 754a238 commit 3911d81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/wheel/metadata.py
Expand Up @@ -139,7 +139,8 @@ def generate_requirements(
condition = " ; " + condition

for new_req in convert_requirements(depends):
yield "Requires-Dist", new_req + condition
canonical_req = str(Requirement(new_req + condition))
yield "Requires-Dist", canonical_req


def pkginfo_to_metadata(egg_info_path: str, pkginfo_path: str) -> Message:
Expand Down
22 changes: 11 additions & 11 deletions tests/test_metadata.py
Expand Up @@ -8,26 +8,26 @@ def test_pkginfo_to_metadata(tmp_path):
("Metadata-Version", "2.1"),
("Name", "spam"),
("Version", "0.1"),
("Requires-Dist", "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
("Requires-Dist", 'pywin32 ; sys_platform=="win32"'),
("Requires-Dist", 'foo @ http://host/foo.zip ; sys_platform=="win32"'),
("Requires-Dist", "pip@ https://github.com/pypa/pip/archive/1.3.1.zip"),
("Requires-Dist", 'pywin32; sys_platform == "win32"'),
("Requires-Dist", 'foo@ http://host/foo.zip ; sys_platform == "win32"'),
("Provides-Extra", "signatures"),
(
"Requires-Dist",
"pyxdg ; (sys_platform!=\"win32\") and extra == 'signatures'",
'pyxdg; sys_platform != "win32" and extra == "signatures"',
),
("Provides-Extra", "empty_extra"),
("Provides-Extra", "extra"),
("Requires-Dist", "bar @ http://host/bar.zip ; extra == 'extra'"),
("Requires-Dist", 'bar@ http://host/bar.zip ; extra == "extra"'),
("Provides-Extra", "faster-signatures"),
("Requires-Dist", "ed25519ll ; extra == 'faster-signatures'"),
("Requires-Dist", 'ed25519ll; extra == "faster-signatures"'),
("Provides-Extra", "rest"),
("Requires-Dist", "docutils >=0.8 ; extra == 'rest'"),
("Requires-Dist", "keyring ; extra == 'signatures'"),
("Requires-Dist", "keyrings.alt ; extra == 'signatures'"),
("Requires-Dist", 'docutils>=0.8; extra == "rest"'),
("Requires-Dist", 'keyring; extra == "signatures"'),
("Requires-Dist", 'keyrings.alt; extra == "signatures"'),
("Provides-Extra", "test"),
("Requires-Dist", "pytest >=3.0.0 ; extra == 'test'"),
("Requires-Dist", "pytest-cov ; extra == 'test'"),
("Requires-Dist", 'pytest>=3.0.0; extra == "test"'),
("Requires-Dist", 'pytest-cov; extra == "test"'),
]

pkg_info = tmp_path.joinpath("PKG-INFO")
Expand Down

0 comments on commit 3911d81

Please sign in to comment.