From 7b5f315830ed25e3f0420fc3def9866d3c53d5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 23 Sep 2023 00:00:30 +0200 Subject: [PATCH] Fix issue with dynamic version in pyproject.toml --- src/pyproject_dependencies/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pyproject_dependencies/__main__.py b/src/pyproject_dependencies/__main__.py index e5a7f0c..4302f7d 100644 --- a/src/pyproject_dependencies/__main__.py +++ b/src/pyproject_dependencies/__main__.py @@ -11,6 +11,7 @@ from build.util import project_wheel_metadata from packaging.requirements import Requirement from packaging.utils import canonicalize_name +from packaging.version import Version from pyproject_metadata import RFC822Message, StandardMetadata from .compat import Protocol, tomllib @@ -93,6 +94,10 @@ def pyproject_metadata( or "optional-dependencies" in metadata.dynamic ): return None + if not metadata.version: + # Fill-in metadata.version because it cannot be dynamic when converting + # to rfc822 format. We don't use it as we are only interested in Requires-Dist. + metadata.version = Version("0") return RFC822MessageAdapter(metadata.as_rfc822())