public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/pyproject-rpm-macros] rawhide: Memoize the NVRA used in file paths to avoid subpackages with custom VR overriding it
Date: Mon, 30 Nov 2026 23:16:22 GMT [thread overview]
Message-ID: <179608058261.1.890043028354781058.rpms-pyproject-rpm-macros-4cf9fe79d50e@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/pyproject-rpm-macros
Branch : rawhide
Commit : 4cf9fe79d50e65402dfa6b0f99939b62d357c309
Author : Miro Hrončok <miro@hroncok.cz>
Date : 2026-11-30T22:42:06+01:00
Stats : +17/-3 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/pyproject-rpm-macros/c/4cf9fe79d50e65402dfa6b0f99939b62d357c309?branch=rawhide
Log:
Memoize the NVRA used in file paths to avoid subpackages with custom VR overriding it
Previously, this would not work:
Name: main
Version: 1
Release: 2
...
%pyproject_extras_subpkg -- uses file with ...main-1-2.x86_64... in path
%package sub
Version: 3
Release: 4
...
%install
...
%pyporject_save_files -- writes file with ...main-3-4.x86_64... in path
Memoizing the NVRA makes the path stable across the specfile,
although the exact value depends on place of first use.
The following does not work on RHEL 9:
%_pyproject_nvra %{global _pyproject_nvra %{name}-%{version}-%{release}.%{_arch}}%{_pyproject_nvra}
It results in:
error: Macro % has illegal name (%global)
Using %{define ...} has the same problem.
---
diff --git a/macros.aaa-pyproject-srpm b/macros.aaa-pyproject-srpm
index dfacb68..1bb906c 100644
--- a/macros.aaa-pyproject-srpm
+++ b/macros.aaa-pyproject-srpm
@@ -16,9 +16,17 @@
# For the main Python it's empty, for all others it's "-3.X".
# - We prefix all created files with %%_pyproject_files_prefix to make them unique.
# Ideally, we would put them into %%{buildsubdir}, but that value changes during the spec.
-# The used value is similar to the one used to define the default %%buildroot.
+# The used value is similar to the one used to define the default %%buildroot on RPM < 4.20.
+# However, %%version and %%release may change throughout the spec file,
+# as individual %%packages can rewrite them. In order to have a stable path,
+# we memoize it on first use. This is not guaranteed to hold the main package values,
+# but we don't really need those semantics as long as the paths are unique enough and stable.
+# As of RPM 4.20+ we do not really need unique paths (%%_builddir is isolated),
+# but we still support older RPM in RHEL 9+10.
+# For RPM 4.16.x on RHEL 9, we also use %%lua:rpm.define rather than %%global.
+%_pyproject_nvra %{lua:rpm.define(rpm.expand("_pyproject_nvra %{name}-%{version}-%{release}.%{_arch}"))}%{_pyproject_nvra}
%_pyproject_files_pkgversion %{expr:"%{python3_pkgversion}" != "3" ? "-%{python3_pkgversion}" : ""}
-%_pyproject_files_prefix %{name}-%{version}-%{release}.%{_arch}%{_pyproject_files_pkgversion}
+%_pyproject_files_prefix %{_pyproject_nvra}%{_pyproject_files_pkgversion}
%_pyproject_dep_overrides %{_builddir}/%{_pyproject_files_prefix}-pyproject-dep-overrides
%pyproject_patch_dependency() %{expand:\\\
diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec
index 2a92829..be33b79 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.24.0
+Version: 1.24.1
Release: 1%{?dist}
# Macro files
@@ -184,6 +184,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%changelog
+* Mon Nov 30 2026 Miro Hrončok <miro@hroncok.cz> - 1.24.1-1
+- Memoize the NVRA used in file paths to avoid subpackages with custom VR overriding it
+- When subpackages defined custom Version and/or Release value, the paths could change mid-specfile
+
* Wed Sep 30 2026 Karolina Surma <ksurma@redhat.com> - 1.24.0-1
- Add %%pyproject_verify_license to assert the spec License: tag matches
the upstream PEP 639 project.license declared in pyproject.toml
diff --git a/tests/double-install.spec b/tests/double-install.spec
index 0ddef73..3521226 100644
--- a/tests/double-install.spec
+++ b/tests/double-install.spec
@@ -19,6 +19,7 @@ and the -D option for %%pyproject_save_files/%%pyproject_check_import/%%pyprojec
%package -n python3-double-markdown-it-py
Summary: markdown-it-py from double-install test
+Version: %{markdown_it_py_version}
%description -n python3-double-markdown-it-py
markdown-it-py subpackage.
@@ -29,6 +30,7 @@ markdown-it-py subpackage.
%package -n python3-double-setuptools-scm
Summary: setuptools_scm from double-install test
+Version: %{setuptools_scm_version}
%description -n python3-double-setuptools-scm
setuptools_scm subpackage.
reply other threads:[~2026-11-30 23:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179608058261.1.890043028354781058.rpms-pyproject-rpm-macros-4cf9fe79d50e@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox