@ -1,8 +1,14 @@
Name: python-rpm-macros
Version: 3.9
Release: 52%{?dist}
Summary: The common Python RPM macros
URL: https://src.fedoraproject.org/rpms/python-rpm-macros/
# macros and lua: MIT
# import_all_modules.py: MIT
# compileall2.py: PSFv2
License: MIT and Python
# Macros:
Source101: macros.python
Source102: macros.python-srpm
@ -16,44 +22,6 @@ Source201: python.lua
%global compileall2_version 0.7.1
Source301: https://github.com/fedora-python/compileall2/raw/v%{compileall2_version}/compileall2.py
Source302: import_all_modules.py
%global pathfix_version 1.0.0
Source303: https://github.com/fedora-python/pathfix/raw/v%{pathfix_version}/pathfix.py
Source304: clamp_source_mtime.py
# BRP scripts
# This one is from redhat-rpm-config < 190
# A new upstream is forming in https://github.com/rpm-software-management/python-rpm-packaging/blob/main/scripts/brp-python-bytecompile
# But our version is riddled with Fedora-isms
# We might eventually move to upstream source + Fedora patches, but we are not there yet
Source401: brp-python-bytecompile
# This one is from https://github.com/rpm-software-management/python-rpm-packaging/blob/main/scripts/brp-python-hardlink
# But we don't use a link in case it changes in upstream, there are no "versions" there yet
# This was removed from RPM 4.17+ so we maintain it here instead
Source402: brp-python-hardlink
# This one is from redhat-rpm-config < 190
# It has no upstream yet
Source403: brp-fix-pyc-reproducibility
# macros and lua: MIT
# import_all_modules.py: MIT
# compileall2.py, clamp_source_mtime.py: PSF-2.0
# pathfix.py: PSF-2.0
# brp scripts: GPL-2.0-or-later
License: MIT AND PSF-2.0 AND GPL-2.0-or-later
# The package version MUST be always the same as %%{__default_python3_version}.
# To have only one source of truth, we load the macro and use it.
# The macro is defined in python-srpm-macros.
%{lua:
if posix.stat(rpm.expand('%{SOURCE102}')) then
rpm.load(rpm.expand('%{SOURCE102}'))
elseif posix.stat('macros.python-srpm') then
-- something is parsing the spec without _sourcedir macro properly set
rpm.load('macros.python-srpm')
end
}
Version: %{__default_python3_version}
Release: 8.1%{?dist}
BuildArch: noarch
@ -80,8 +48,7 @@ python?-devel packages require it. So install a python-devel package instead.
Summary: RPM macros for building Python source packages
# For directory structure and flags macros
# Versions before 190 contained some brp scripts moved into python-srpm-macros
Requires: redhat-rpm-config >= 190
Requires: redhat-rpm-config
# We bundle our own software here :/
Provides: bundled(python3dist(compileall2)) = %{compileall2_version}
@ -99,6 +66,15 @@ Requires: python-srpm-macros = %{version}-%{release}
# For %%py_setup and import_all_modules.py
Requires: python-rpm-macros = %{version}-%{release}
# We obsolete the old python39-rpm-macros for a smoother upgrade from RHEL8.
# Since python39-rpm-macros are built from the python39 component in RHEL 8,
# they're fully versioned (currently `0:3.9.7`), with the patch version likely
# to increase in the future. RPM sorts this number as higher than `3.9`, which
# is the version we have in RHEL 9. Therefore we're obsoleting with an Epoch 1
# so that all versions from RHEL 8 are obsoleted (but we keep the possibility
# of increasing the epoch in RHEL 8 to stop this).
Obsoletes: python39-rpm-macros < 1:%{version}-%{release}
%description -n python3-rpm-macros
RPM macros for building Python 3 packages.
@ -107,10 +83,6 @@ RPM macros for building Python 3 packages.
%autosetup -c -T
cp -a %{sources} .
# We want to have shebang in the script upstream but not here so
# the package with macros does not depend on Python.
sed -i '1s=^#!/usr/bin/env python3==' pathfix.py
%install
mkdir -p %{buildroot}%{rpmmacrodir}
@ -121,41 +93,22 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm python.lua
mkdir -p %{buildroot}%{_rpmconfigdir}/redhat
install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
install -m 644 clamp_source_mtime.py %{buildroot}%{_rpmconfigdir}/redhat/
install -m 644 import_all_modules.py %{buildroot}%{_rpmconfigdir}/redhat/
install -m 644 pathfix.py %{buildroot}%{_rpmconfigdir}/redhat/
install -m 755 brp-* %{buildroot}%{_rpmconfigdir}/redhat/
# We define our own BRPs here to use the ones from the %%{buildroot},
# that way, this package can be built when it includes them for the first time.
# It also ensures that:
# - our BRPs can execute
# - if our BRPs affect this package, we don't need to build it twice
%define add_buildroot() %{lua:print((macros[macros[1]]:gsub(macros._rpmconfigdir, macros.buildroot .. macros._rpmconfigdir)))}
%global __brp_python_bytecompile %{add_buildroot __brp_python_bytecompile}
%global __brp_python_hardlink %{add_buildroot __brp_python_hardlink}
%global __brp_fix_pyc_reproducibility %{add_buildroot __brp_fix_pyc_reproducibility}
%check
# no macros in comments
grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
! grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.*
%files
%{rpmmacrodir}/macros.python
%{rpmmacrodir}/macros.pybytecompile
%{_rpmconfigdir}/redhat/import_all_modules.py
%{_rpmconfigdir}/redhat/pathfix.py
%files -n python-srpm-macros
%{rpmmacrodir}/macros.python-srpm
%{_rpmconfigdir}/redhat/compileall2.py
%{_rpmconfigdir}/redhat/clamp_source_mtime.py
%{_rpmconfigdir}/redhat/brp-python-bytecompile
%{_rpmconfigdir}/redhat/brp-python-hardlink
%{_rpmconfigdir}/redhat/brp-fix-pyc-reproducibility
%{_rpmluadir}/fedora/srpm/python.lua
%files -n python3-rpm-macros
@ -163,157 +116,77 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
%changelog
* Tue Jun 25 2024 Cristian Le <fedora@lecris.me> - 3.12-8.1
- %%python_extras_subpkg: Add option -a to include BuildArch: noarch
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.12-8
- Bump release for June 2024 mass rebuild
* Thu Jan 25 2024 Miro Hrončok <mhroncok@redhat.com> - 3.12-7
- %%py3_test_envvars: Only set $PYTEST_XDIST_AUTO_NUM_WORKERS if not already set
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.12-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Mon Oct 09 2023 Maxwell G <maxwell@gtmx.me> - 3.12-5
- Fix python macro memoizing to account for changing %%__python3
* Tue Sep 05 2023 Maxwell G <maxwell@gtmx.me> - 3.12-4
- Remove %%py3_build_egg and %%py3_install_egg macros.
* Wed Aug 09 2023 Karolina Surma <ksurma@redhat.com> - 3.12-3
- Declare the license as an SPDX expression
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Tue Jun 13 2023 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.12-1
- Update main Python to Python 3.12
- https://fedoraproject.org/wiki/Changes/Python3.12
* Thu Mar 16 2023 Miro Hrončok <mhroncok@redhat.com> - 3.11-10
- Don't assume %%_smp_mflags only ever contains -jX, use -j%%_smp_build_ncpus directly
- Fixes: rhbz#2179149
* Fri Jan 20 2023 Miro Hrončok <mhroncok@redhat.com> - 3.11-9
- Memoize values of macros that execute python to get their value
- Fixes: rhbz#2155505
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Mon Dec 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-7
- Bytecompilation: Unset $SOURCE_DATE_EPOCH when %%clamp_mtime_to_source_date_epoch is not set
- Bytecompilation: Pass --invalidation-mode=timestamp to compileall (on Python 3.7+)
- Bytecompilation: Clamp source mtime: https://fedoraproject.org/wiki/Changes/ReproducibleBuildsClampMtimes
- Bytecompilation: Compile Python files in parallel, according to %%_smp_mflags
* Sun Nov 13 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-6
- Set PYTEST_XDIST_AUTO_NUM_WORKERS=%%{_smp_build_ncpus} from %%pytest
- pytest-xdist 3+ respects this value when -n auto is used
- Expose the environment variables used by %%pytest via %%{py3_test_envvars}
* Tue Oct 25 2022 Lumír Balhar <lbalhar@redhat.com> - 3.11-5
- Include pathfix.py in this package
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.10-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Tue Jul 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-3
- Add "P" to %%py3_shbang_opts, %%py3_shbang_opts_nodash, %%py3_shebang_flags
and to %%py_shbang_opts, %%py_shbang_opts_nodash, %%py_shebang_flags
- https://fedoraproject.org/wiki/Changes/PythonSafePath
* Mon Jun 20 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-2
- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311
* Mon Jun 13 2022 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.11-1
- Update main Python to Python 3.11
- https://fedoraproject.org/wiki/Changes/Python3.11
* Thu May 26 2022 Owen Taylor <otaylor@redhat.com> - 3.10-18
- Support installing to %%{_prefix} other than /usr
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 3.10-17
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 3.9-52
- %%py_provides: Do not generate Obsoletes for names containing parentheses
- Related: rhbz#1990421
* Mon Jan 31 2022 Miro Hrončok <mhroncok@redhat.com> - 3.10-16
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 3.9-51
- Add Obsoletes tags with the python39- prefix for smoother upgrade from RHEL8
- Related: rhbz#1990421
* Tue Feb 01 2022 Miro Hrončok <mhroncok@redhat.com> - 3.9-50
- Explicitly opt-out from Python name-based provides and obsoletes generators
* Tue Dec 21 2021 Tomas Orsava <torsava@redhat.com> - 3.10-15
* Wed Jan 19 2022 Tomas Orsava <torsava@redhat.com> - 3.9-49
- Add lua helper functions to make it possible to automatically generate
Obsoletes tags
- Modify the %%py_provides macro to also generate Obsoletes tags on CentOS/RHEL
- Resolves: rhbz#1990421
* Tue Dec 21 2021 Karolina Surma <ksurma@redhat.com> - 3.9-48
- Fix CI test configuration, so that pytest can import the package code
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-14
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-47
- Set %%__python3 value according to %%python3_pkgversion
I.e. when %%python3_pkgversion is 3.12, %%__python3 is /usr/bin/python3.12
* Mon Nov 01 2021 Karolina Surma <ksurma@redhat.com> - 3.10-13
* Mon Nov 01 2021 Karolina Surma <ksurma@redhat.com> - 3.9-46
- Fix multiline arguments processing for %%py_check_import
Resolves: rhbz#2018809
- Fix %%py_shebang_flags handling within %%py_check_import
Resolves: rhbz#2018615
- Process .pth files in buildroot's sitedirs in %%py_check_import
Resolves: rhbz#2018551
- Move import_all_modules.py from python-srpm-macros to python-rpm-macros
* Mon Oct 25 2021 Karolina Surma <ksurma@redhat.com> - 3.10-12
* Mon Oct 25 2021 Karolina Surma <ksurma@redhat.com> - 3.9-45
- Introduce -f (read from file) option to %%py{3}_check_import
- Introduce -t (filter top-level modules) option to %%py{3}_check_import
- Introduce -e (exclude module globs) option to %%py{3}_check_import
* Wed Oct 20 2021 Tomas Orsava <torsava@redhat.com> - 3.10-11
- Define a new macros %%python_wheel_dir and %%python_wheel_pkg_prefix
* Tue Oct 12 2021 Lumír Balhar <lbalhar@redhat.com> - 3.10-10
- Non-existing path in py_reproducible_pyc_path causes build to fail
Resolves: rhbz#2011056
* Thu Sep 09 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-9
* Thu Sep 09 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-44
- Set $RPM_BUILD_ROOT in %%{python3_...} macros
to allow selecting alternate sysconfig install scheme based on that variable
* Thu Sep 09 2021 Petr Viktorin <pviktori@redhat.com> - 3.10-8
- Use --hardlink-dupes in %%py_byte_compile and brp-python-bytecompile
(for Python 3)
- Resolves: rhbz#1977895
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.9-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Aug 11 2021 Tomas Orsava <torsava@redhat.com> - 3.9-43
- Define a new macros %%python_wheel_dir and %%python_wheel_pkg_prefix
- Related: rhbz#1982668
* Wed Jul 07 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-6
- Move Python related BuildRoot Policy scripts from redhat-rpm-config to python-srpm-macros
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.9-42
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jul 07 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-5
* Wed Jul 07 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-41
- Introduce %%py3_check_import
* Wed Jun 30 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-4
- Include brp-python-hardlink in python-srpm-macros since it is no longer in RPM 4.17+
* Mon Jun 28 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-3
* Mon Jun 28 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-40
- %%pytest: Set $PYTEST_ADDOPTS when %%{__pytest_addopts} is defined
- Related: rhzb#1935212
* Tue Jun 15 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-2
* Tue Jun 15 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-39
- Fix %%python_provide when fed python3.10-foo to obsolete python-foo instead of python--foo
* Tue Jun 01 2021 Miro Hrončok <mhroncok@redhat.com> - 3.10-1
- Update main Python to Python 3.10
- https://fedoraproject.org/wiki/Changes/Python3.10
* Tue Apr 27 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-38
- Escape %% symbols in macro files comments
- Fixes: rhbz#1953910
* Wed Apr 07 2021 Karolina Surma <ksurma@redhat.com> - 3.9-37
* Fri Apr 16 2021 Karolina Surma <ksurma@redhat.com> - 3.9-37
- Use sysconfig.get_path() to get %%python3_sitelib and %%python3_sitearch
- Fixes: rhbz#1946972
- Fixes: rhbz#1947468
* Mon Mar 29 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-36
* Fri Apr 16 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-36.1
- Allow commas as argument separator for extras names in %%python_extras_subpkg
- Fixes: rhbz#1936486
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.9-36
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Sat Feb 20 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-35
- Fix %%python_extras_subpkg with underscores in extras names