Skip to content

Commit

Permalink
fix: workaround unsupported metadata version 2.4 in pkginfo (#9881)
Browse files Browse the repository at this point in the history
Co-authored-by: Randy Döring <[email protected]>
  • Loading branch information
finswimmer and radoering authored Dec 2, 2024
1 parent cdfd955 commit 9e2a8bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ def _from_distribution(
:param dist: The distribution instance to parse information from.
"""
if dist.metadata_version not in pkginfo.distribution.HEADER_ATTRS:
# 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
raise ValueError(f"Unknown metadata version: {dist.metadata_version}")
Expand Down
Binary file not shown.
7 changes: 5 additions & 2 deletions tests/inspection/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,13 @@ def test_info_from_wheel(demo_wheel: Path) -> None:
assert info._source_url == demo_wheel.resolve().as_posix()


def test_info_from_wheel_metadata_version_23(fixture_dir: FixtureDirGetter) -> None:
@pytest.mark.parametrize("version", ["23", "24"])
def test_info_from_wheel_metadata_versions(
version: str, fixture_dir: FixtureDirGetter
) -> None:
path = (
fixture_dir("distributions")
/ "demo_metadata_version_23-0.1.0-py2.py3-none-any.whl"
/ f"demo_metadata_version_{version}-0.1.0-py2.py3-none-any.whl"
)
info = PackageInfo.from_wheel(path)
demo_check_info(info)
Expand Down

0 comments on commit 9e2a8bd

Please sign in to comment.