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

info: require pkginfo >= 1.12 for METADATA 2.4 support and loosen check for unknown METADATA versions #9888

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ installer = "^0.7.0"
keyring = "^25.1.0"
# packaging uses calver, so version is unclamped
packaging = ">=24.0"
pkginfo = "^1.10"
pkginfo = "^1.12"
platformdirs = ">=3.0.0,<5"
pyproject-hooks = "^1.0.0"
requests = "^2.26"
13 changes: 7 additions & 6 deletions src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
@@ -265,12 +265,13 @@ def _from_distribution(
:param dist: The distribution instance to parse information from.
"""
# The current pkginfo version (1.11.2) does not support 2.4.
# The fields we are interested in can be parsed nevertheless.
supported_metadata_versions = {*pkginfo.distribution.HEADER_ATTRS.keys(), "2.4"}
if dist.metadata_version not in supported_metadata_versions:
# This check can be replaced once upstream implements strict parsing
# https://bugs.launchpad.net/pkginfo/+bug/2058697
# If the METADATA version is greater than the highest supported version,
# pkginfo prints a warning and tries to parse the fields from the highest
# known version. Assuming that METADATA versions adhere to semver,
# this should be safe for minor updates.
if not dist.metadata_version or dist.metadata_version.split(".")[0] not in {
v.split(".")[0] for v in pkginfo.distribution.HEADER_ATTRS
}:
raise ValueError(f"Unknown metadata version: {dist.metadata_version}")

requirements = cls._requirements_from_distribution(dist)
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/inspection/test_info.py
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ def test_info_from_wheel(demo_wheel: Path) -> None:
assert info._source_url == demo_wheel.resolve().as_posix()


@pytest.mark.parametrize("version", ["23", "24"])
@pytest.mark.parametrize("version", ["23", "24", "299"])
def test_info_from_wheel_metadata_versions(
version: str, fixture_dir: FixtureDirGetter
) -> None: