From 0f43efad75ea09636ada12fc03c27b2325eb1add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 11 Jul 2025 12:24:36 +0200 Subject: [PATCH] %pyproject_buildrequires: Do not generate BuildRequires from Requires core metadata fields See https://packaging.python.org/en/latest/specifications/core-metadata/#requires That field is deprecated and should include importable module names, not distribution packages. We have no RPM Provides for importable names. Treating this like python3dist() Requires is wrong and may result in stuff like: No match for argument: python3dist(pkg-resources) For packages using python-distutils-extra. See https://bugzilla.redhat.com/show_bug.cgi?id=2378463#c2 This bug existed from the very beginning of the %pyproject_buildrequires, but the field is almost unused in real packages, so it was not noticed until we asked all Python packages to be ported to the new macros. --- I considered flattening the structure returned from requires_from_parsed_metadata_file, but then we would need to hardcode "Requires-Dist" in various source= declarations, so I kept the structure as is. (cherry picked from Fedora commit a4e0e043445f5cd08aa389e1cffca8afc56196d3) --- pyproject-rpm-macros.spec | 7 ++++++- pyproject_buildrequires.py | 2 +- pyproject_buildrequires_testcases.yaml | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index aa0bf9c..8b625f5 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -14,7 +14,7 @@ License: MIT # Increment Y and reset Z when new macros or features are added # Increment Z when this is a bugfix or a cosmetic change # Dropping support for EOL Fedoras is *not* considered a breaking change -Version: 1.18.2 +Version: 1.18.3 Release: 1%{?dist} # Macro files @@ -191,6 +191,11 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog +* Fri Jul 11 2025 Miro HronĨok - 1.18.3-1 +- %%pyproject_buildrequires: Do not generate BuildRequires from Requires core metadata fields +- That field is deprecated and should include importable module names, not distribution packages +- Related: rhbz#2378463 + * Mon May 19 2025 Maxwell G - 1.18.2-1 - Fix handling of config_settings in %%pyproject_buildrequires diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index f4c38ab..bba4f00 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -309,7 +309,7 @@ def parse_metadata_file(metadata_file): def requires_from_parsed_metadata_file(message): - return {k: message.get_all(k, ()) for k in ('Requires', 'Requires-Dist')} + return {k: message.get_all(k, ()) for k in ('Requires-Dist',)} def package_name_from_parsed_metadata_file(message): diff --git a/pyproject_buildrequires_testcases.yaml b/pyproject_buildrequires_testcases.yaml index bfbb5bd..ae26569 100644 --- a/pyproject_buildrequires_testcases.yaml +++ b/pyproject_buildrequires_testcases.yaml @@ -1608,3 +1608,23 @@ tox with dependency_groups: python3dist(pytest) >= 5 python3dist(pytest-mock) result: 0 + +Plain Requires fields in core metadata is ignored: + installed: + setuptools: 50 + wheel: 1 + include_runtime: true + setup.py: | + from setuptools import setup + setup( + name='test', + version='0.1', + requires=['ignore_me'], + ) + expected: + - | # setuptools 70+ + python3dist(setuptools) >= 40.8 + - | # setuptools < 70 + python3dist(setuptools) >= 40.8 + python3dist(wheel) + result: 0