From cb4ded8442d53bb9f9b2a296cb479322f001a1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:22:19 +0100 Subject: [PATCH 1/2] info: require `pkginfo >= 1.12` for METADATA 2.4 support and loosen check for unknown METADATA versions (#9888) (cherry picked from commit a3cae0cb2676bc6408f7205f167fbf4abf72d0be) --- poetry.lock | 10 +++++----- pyproject.toml | 2 +- src/poetry/inspection/info.py | 10 +++++++--- ...etadata_version_24-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1152 bytes ...tadata_version_299-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1153 bytes tests/inspection/test_info.py | 14 ++++++++++++++ 6 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl create mode 100644 tests/fixtures/distributions/demo_metadata_version_299-0.1.0-py2.py3-none-any.whl diff --git a/poetry.lock b/poetry.lock index b2689d4a90c..e4105d462fd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -925,13 +925,13 @@ ptyprocess = ">=0.5" [[package]] name = "pkginfo" -version = "1.10.0" +version = "1.12.0" description = "Query metadata from sdists / bdists / installed packages." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pkginfo-1.10.0-py3-none-any.whl", hash = "sha256:889a6da2ed7ffc58ab5b900d888ddce90bce912f2d2de1dc1c26f4cb9fe65097"}, - {file = "pkginfo-1.10.0.tar.gz", hash = "sha256:5df73835398d10db79f8eecd5cd86b1f6d29317589ea70796994d49399af6297"}, + {file = "pkginfo-1.12.0-py3-none-any.whl", hash = "sha256:dcd589c9be4da8973eceffa247733c144812759aa67eaf4bbf97016a02f39088"}, + {file = "pkginfo-1.12.0.tar.gz", hash = "sha256:8ad91a0445a036782b9366ef8b8c2c50291f83a553478ba8580c73d3215700cf"}, ] [package.extras] @@ -1618,4 +1618,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "e793d16c7f8a014e1fc36d16b280e271032f4b8cd152ede01638e61a7c6026d8" +content-hash = "b4f0da10f17e674f506b690ee799443cf9115fdf8b6fe96f8742ad19d5f8a503" diff --git a/pyproject.toml b/pyproject.toml index f83056f6ee0..59eb9be32bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ keyring = "^24.0.0" # packaging uses calver, so version is unclamped packaging = ">=23.1" pexpect = "^4.7.0" -pkginfo = "^1.10" +pkginfo = "^1.12" platformdirs = ">=3.0.0,<5" pyproject-hooks = "^1.0.0" requests = "^2.26" diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index 02cf66a2b35..747485e6dab 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -245,9 +245,13 @@ def _from_distribution( :param dist: The distribution instance to parse information from. """ - if dist.metadata_version not in pkginfo.distribution.HEADER_ATTRS: - # 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 = None 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/fixtures/distributions/demo_metadata_version_299-0.1.0-py2.py3-none-any.whl b/tests/fixtures/distributions/demo_metadata_version_299-0.1.0-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..8523f2cbe1f914f1a3aae6227cc4e656d5050f6a GIT binary patch literal 1153 zcmWIWW@Zs#U|`^2Xwz+rbaTIVTbhx9;W!fmgDg-qB{er+*Feuu&pm@-R){;QzV10t=((sq0ENZ?lo#mN#c>-kj}uDmnr3n>hSu)>t(&iDmq&^uAkh zuXl@|L)^rD47Z+4SayNaoOwW%5U%oz(bXR zLDA#ws$!Ybz|iCdhO9KMPz`c*_78H&J+r&4$$)|3!rgpNg9)DsUO4y)@Glf`VbZho z;&NG;sajjNH}=jR`GTjfXV2qac0y9 z0rS5VZ2T(Tw06>#xfb5@{CErI%>0wDuqlT-GRT*0Rq^uYHp`~mJ#<5_`swi{@7(89 zhl+pneDv!9+r?F_`XUS0Wk3BqD>bHBVTb&(Ej*qPZQF(4*+-O|ncUpR{mJ3Sr4BVo zbJKaNyuW-6<`>PrqbqlI9s9oCcgtC0(^wf3%2-juz+oy6dpOYV5kM@3D-6OtTwQ&5 zPdRcmCFS6efNI76)(8VR=c@i%iPatEY87# zz25{yay+i_4wsdd@(XRCI67R=|%n7Zsp6 zAfNyy31l8Fs4_+d2?qP4$7^T0-v*`*Q~ None: assert info._source_url == demo_wheel.resolve().as_posix() +@pytest.mark.parametrize("version", ["24", "299"]) +def test_info_from_wheel_metadata_versions( + version: str, fixture_dir: FixtureDirGetter +) -> None: + path = ( + fixture_dir("distributions") + / f"demo_metadata_version_{version}-0.1.0-py2.py3-none-any.whl" + ) + info = PackageInfo.from_wheel(path) + demo_check_info(info) + assert info._source_type == "file" + assert info._source_url == path.resolve().as_posix() + + def test_info_from_wheel_metadata_version_unknown( fixture_dir: FixtureDirGetter, ) -> None: From 6cee715e018feffd17dcd5aff20b4e253c3b79ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:38:14 +0100 Subject: [PATCH 2/2] ci: macos-12 is not available anymore --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7125ba2c3f1..9b4ffe70b0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,7 +35,7 @@ jobs: - os: Windows image: windows-2022 - os: macOS - image: macos-12 + image: macos-13 fail-fast: false defaults: run: