From a86bb31b8a380302a796e145e600a5e1f0db23b5 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 05:46:41 +0100 Subject: [PATCH] info: require pkginfo >= 1.12 for METADATA 2.4 support and loosen check for unknown METADATA versions --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- src/poetry/inspection/info.py | 13 +++++++------ ...tadata_version_299-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1153 bytes tests/inspection/test_info.py | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) 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 5a6b6a44b07..31caf64d256 100644 --- a/poetry.lock +++ b/poetry.lock @@ -914,13 +914,13 @@ files = [ [[package]] name = "pkginfo" -version = "1.11.1" +version = "1.12.0" description = "Query metadata from sdists / bdists / installed packages." optional = false python-versions = ">=3.8" files = [ - {file = "pkginfo-1.11.1-py3-none-any.whl", hash = "sha256:bfa76a714fdfc18a045fcd684dbfc3816b603d9d075febef17cb6582bea29573"}, - {file = "pkginfo-1.11.1.tar.gz", hash = "sha256:2e0dca1cf4c8e39644eed32408ea9966ee15e0d324c62ba899a393b3c6b467aa"}, + {file = "pkginfo-1.12.0-py3-none-any.whl", hash = "sha256:dcd589c9be4da8973eceffa247733c144812759aa67eaf4bbf97016a02f39088"}, + {file = "pkginfo-1.12.0.tar.gz", hash = "sha256:8ad91a0445a036782b9366ef8b8c2c50291f83a553478ba8580c73d3215700cf"}, ] [package.extras] @@ -1582,4 +1582,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "95b92662eda25340562e13daba629f975222cc1baeafa1f78d9ceaeb652a7849" +content-hash = "0663eb99762d70c3d26b04a078066ebb856a5d1e109de12108820e7ef9eaf11b" diff --git a/pyproject.toml b/pyproject.toml index 8fac358c767..da7f64b25ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ installer = "^0.7.0" keyring = "^25.1.0" # packaging uses calver, so version is unclamped packaging = ">=24.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 f30efcaefa5..23a64604aa4 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -265,12 +265,13 @@ def _from_distribution( :param dist: The distribution instance to parse information from. """ - # 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 + # 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 = cls._requirements_from_distribution(dist) 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", ["23", "24"]) +@pytest.mark.parametrize("version", ["23", "24", "299"]) def test_info_from_wheel_metadata_versions( version: str, fixture_dir: FixtureDirGetter ) -> None: