From a3c16f2a087066bb6ec48cb8ec664de487e5ee7f Mon Sep 17 00:00:00 2001 From: finswimmer Date: Mon, 2 Dec 2024 16:26:51 +0100 Subject: [PATCH 1/2] fix: workaround unsupported metadata version 2.4 in pkginfo --- src/poetry/inspection/info.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index 08c7a7918b6..f30efcaefa5 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -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}") From 808f54b17721cf72e1396a174a6a5733773274bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:34:11 +0100 Subject: [PATCH 2/2] add test --- ...etadata_version_24-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1152 bytes tests/inspection/test_info.py | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl diff --git a/tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl b/tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..4c8cf2f72b3b7effa7b0513aa5d694ed7165e165 GIT binary patch literal 1152 zcmWIWW@Zs#U|`^2;GWVHDY0kG2PsAdhGR?&46;Dcl+@gOT?0KsJp;Xz%;FN=%)GRG zeP7oQM;FHs$Eg$VdL4EUXnp@(^H^M_q4#VzW^K(bF_vr{v9DFLd>$v6MSpjHqx@55 z-;C(nUMs?PTF?1BcV^>G^>$UOo_QxDR!TD(`bYG2u}oQF^7}J;%?b9LcT=4ZG#W$@sJZvcx`}{?uZhks!_-<9rl3%=j{T59c7Z_mV^XI`9I5VUD! zLYME;!)Fzm{#%zWezeZU-`dPAwsKxc-kj3BIpujvbOPiz@%YcIv1(=#%lKF6eYfgf z?-oCYz{&dq4oMHa5he)@S8KfLIDw7=(Mcy87^* za^z}I5MaHqclie<<+KZjxLtO4tk`;RdCQDWPw{*E?)`czUT~SMc5}g&xu4TmoPz~> zzX^)uUfZp=$2(3R_*vKn0t|H^RmzVx;vJCJ#uKlk+U^0=K$?yP-JN0Dtsvh zWPz{%5QEaWetdjpUS>&ryk0?Ne0*7IQE_H|UVOZQt%5o@2dHxecr!BDGvLZCDnN5U zKmkk=$U9t6WsD3G40{azC_iwy4NM)V0A!sAGsHS<=?JE}fiV=Q7i(69q$+fS&?5t3 tP$V$lV>JjIH3)M+Ixs^KX3mnv7f^GM!!*E~l?|kV1qkhc4%T4?@c`m}kCgxb literal 0 HcmV?d00001 diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index 776cafa60d1..b0cc6f1c3db 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -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)