Skip to content

Commit 2b7f148

Browse files
committed
info: require pkginfo >= 1.12 for METADATA 2.4 support and loosen check for unknown METADATA versions
1 parent bd4adcb commit 2b7f148

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ installer = "^0.7.0"
4242
keyring = "^25.1.0"
4343
# packaging uses calver, so version is unclamped
4444
packaging = ">=24.0"
45-
pkginfo = "^1.10"
45+
pkginfo = "^1.12"
4646
platformdirs = ">=3.0.0,<5"
4747
pyproject-hooks = "^1.0.0"
4848
requests = "^2.26"

src/poetry/inspection/info.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ def _from_distribution(
265265
266266
:param dist: The distribution instance to parse information from.
267267
"""
268-
# The current pkginfo version (1.11.2) does not support 2.4.
269-
# The fields we are interested in can be parsed nevertheless.
270-
supported_metadata_versions = {*pkginfo.distribution.HEADER_ATTRS.keys(), "2.4"}
271-
if dist.metadata_version not in supported_metadata_versions:
272-
# This check can be replaced once upstream implements strict parsing
273-
# https://bugs.launchpad.net/pkginfo/+bug/2058697
268+
# If the METADATA version is greater than the highest supported version,
269+
# pkginfo prints a warning and tries to parse the fields from the highest
270+
# known version. Assuming that METADATA versions adhere to semver,
271+
# this should be safe for minor updates.
272+
if dist.metadata_version and dist.metadata_version.split(".")[0] not in {
273+
v.split(".")[0] for v in pkginfo.distribution.HEADER_ATTRS
274+
}:
274275
raise ValueError(f"Unknown metadata version: {dist.metadata_version}")
275276

276277
requirements = cls._requirements_from_distribution(dist)
Binary file not shown.

tests/inspection/test_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_info_from_wheel(demo_wheel: Path) -> None:
202202
assert info._source_url == demo_wheel.resolve().as_posix()
203203

204204

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

0 commit comments

Comments
 (0)