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..b9b9db7ef57 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 dist.metadata_version and 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 00000000000..8523f2cbe1f Binary files /dev/null and b/tests/fixtures/distributions/demo_metadata_version_299-0.1.0-py2.py3-none-any.whl differ diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index b0cc6f1c3db..cbdd06f038f 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -202,7 +202,7 @@ def test_info_from_wheel(demo_wheel: Path) -> 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: