From 9e2a8bd5ff6de05d9af03fbefce647b673b13352 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Mon, 2 Dec 2024 18:54:15 +0100 Subject: [PATCH] fix: workaround unsupported metadata version 2.4 in pkginfo (#9881) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com> --- src/poetry/inspection/info.py | 5 ++++- ...etadata_version_24-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1152 bytes tests/inspection/test_info.py | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl 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}") 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)