Blame SPECS/pyproject-rpm-macros.spec

7ef706
Name:           pyproject-rpm-macros
7ef706
Summary:        RPM macros for PEP 517 Python packages
7ef706
License:        MIT
7ef706
7ef706
# Disable tests on RHEL9 as to not pull in the test dependencies
7ef706
# Specify --with tests to run the tests e.g. on EPEL
7ef706
%bcond_with tests
7ef706
7ef706
# The idea is to follow the spirit of semver
7ef706
# Given version X.Y.Z:
7ef706
#   Increment X and reset Y.Z when there is a *major* incompatibility
7ef706
#   Increment Y and reset Z when new macros or features are added
7ef706
#   Increment Z when this is a bugfix or a cosmetic change
7ef706
# Dropping support for EOL Fedoras is *not* considered a breaking change
20b2b6
Version:        1.3.3
7ef706
Release:        1%{?dist}
7ef706
7ef706
# Macro files
7ef706
Source001:      macros.pyproject
7ef706
7ef706
# Implementation files
7ef706
Source101:      pyproject_buildrequires.py
7ef706
Source102:      pyproject_save_files.py
7ef706
Source103:      pyproject_convert.py
7ef706
Source104:      pyproject_preprocess_record.py
7ef706
Source105:      pyproject_construct_toxenv.py
7ef706
Source106:      pyproject_requirements_txt.py
20b2b6
Source107:      pyproject_wheel.py
7ef706
7ef706
# Tests
7ef706
Source201:      test_pyproject_buildrequires.py
7ef706
Source202:      test_pyproject_save_files.py
7ef706
Source203:      test_pyproject_requirements_txt.py
7ef706
Source204:      compare_mandata.py
7ef706
7ef706
# Test data
7ef706
Source301:      pyproject_buildrequires_testcases.yaml
7ef706
Source302:      pyproject_save_files_test_data.yaml
7ef706
Source303:      test_RECORD
7ef706
7ef706
# Metadata
7ef706
Source901:      README.md
7ef706
Source902:      LICENSE
7ef706
7ef706
URL:            https://src.fedoraproject.org/rpms/pyproject-rpm-macros
7ef706
7ef706
BuildArch:      noarch
7ef706
7ef706
%if %{with tests}
20b2b6
BuildRequires:  python3dist(pytest)
20b2b6
BuildRequires:  python3dist(pyyaml)
20b2b6
BuildRequires:  python3dist(packaging)
20b2b6
BuildRequires:  python3dist(pip)
20b2b6
BuildRequires:  python3dist(setuptools)
20b2b6
BuildRequires:  python3dist(tox-current-env) >= 0.0.6
20b2b6
BuildRequires:  python3dist(wheel)
20b2b6
BuildRequires:  (python3dist(toml) if python3-devel < 3.11)
7ef706
%endif
7ef706
7ef706
# We build on top of those:
20b2b6
BuildRequires:  python-rpm-macros
20b2b6
BuildRequires:  python-srpm-macros
20b2b6
BuildRequires:  python3-rpm-macros
20b2b6
Requires:       python-rpm-macros
20b2b6
Requires:       python-srpm-macros
20b2b6
Requires:       python3-rpm-macros
7ef706
7ef706
# We use the following tools outside of coreutils
20b2b6
Requires:       /usr/bin/find
20b2b6
Requires:       /usr/bin/sed
7ef706
7ef706
%description
7ef706
These macros allow projects that follow the Python packaging specifications
7ef706
to be packaged as RPMs.
7ef706
7ef706
They work for:
7ef706
7ef706
* traditional Setuptools-based projects that use the setup.py file,
7ef706
* newer Setuptools-based projects that have a setup.cfg file,
7ef706
* general Python projects that use the PEP 517 pyproject.toml file
7ef706
  (which allows using any build system, such as setuptools, flit or poetry).
7ef706
7ef706
These macros replace %%py3_build and %%py3_install,
7ef706
which only work with setup.py.
7ef706
7ef706
7ef706
%prep
7ef706
# Not strictly necessary but allows working on file names instead
7ef706
# of source numbers in install section
7ef706
%setup -c -T
7ef706
cp -p %{sources} .
7ef706
7ef706
%build
7ef706
# nothing to do, sources are not buildable
7ef706
7ef706
%install
7ef706
mkdir -p %{buildroot}%{_rpmmacrodir}
7ef706
mkdir -p %{buildroot}%{_rpmconfigdir}/redhat
20b2b6
install -pm 644 macros.pyproject %{buildroot}%{_rpmmacrodir}/
20b2b6
install -pm 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_convert.py %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_save_files.py  %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_preprocess_record.py %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_construct_toxenv.py %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_requirements_txt.py %{buildroot}%{_rpmconfigdir}/redhat/
20b2b6
install -pm 644 pyproject_wheel.py %{buildroot}%{_rpmconfigdir}/redhat/
7ef706
7ef706
%if %{with tests}
7ef706
%check
7ef706
export HOSTNAME="rpmbuild"  # to speedup tox in network-less mock, see rhbz#1856356
20b2b6
%pytest -vv --doctest-modules
7ef706
7ef706
# brp-compress is provided as an argument to get the right directory macro expansion
7ef706
%{python3} compare_mandata.py -f %{_rpmconfigdir}/brp-compress
7ef706
%endif
7ef706
7ef706
7ef706
%files
7ef706
%{_rpmmacrodir}/macros.pyproject
7ef706
%{_rpmconfigdir}/redhat/pyproject_buildrequires.py
7ef706
%{_rpmconfigdir}/redhat/pyproject_convert.py
7ef706
%{_rpmconfigdir}/redhat/pyproject_save_files.py
7ef706
%{_rpmconfigdir}/redhat/pyproject_preprocess_record.py
7ef706
%{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py
7ef706
%{_rpmconfigdir}/redhat/pyproject_requirements_txt.py
20b2b6
%{_rpmconfigdir}/redhat/pyproject_wheel.py
7ef706
7ef706
%doc README.md
7ef706
%license LICENSE
7ef706
7ef706
%changelog
20b2b6
* Tue Aug 09 2022 Karolina Surma <ksurma@redhat.com> - 1.3.3-1
20b2b6
- Don't fail %%pyproject_save_files '*' if no modules are detected
20b2b6
20b2b6
* Wed Jun 15 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.2-1
20b2b6
- Update %%pyproject_build_lib to support setuptools 62.1.0 and later
20b2b6
- %%pyproject_buildrequires: When extension modules are built,
20b2b6
  support https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects
20b2b6
20b2b6
* Fri May 27 2022 Owen Taylor <otaylor@redhat.com> - 1.3.1-1
20b2b6
- %%pyproject_install: pass %%{_prefix} explicitly to pip install
20b2b6
20b2b6
* Thu May 12 2022 Miro Hrončok <mhroncok@redhat.com> - 1.3.0-1
20b2b6
- Use tomllib from the standard library on Python 3.11+
20b2b6
20b2b6
* Wed Apr 27 2022 Miro Hrončok <mhroncok@redhat.com> - 1.2.0-1
20b2b6
- %%pyproject_buildrequires: Add provisional -w flag for build backends without
20b2b6
  prepare_metadata_for_build_wheel hook
20b2b6
  When used, the wheel is built in %%pyproject_buildrequires
20b2b6
  and information about runtime requires and extras is read from that wheel.
20b2b6
20b2b6
* Tue Apr 12 2022 Miro Hrončok <mhroncok@redhat.com> - 1.1.0-1
20b2b6
- %%pyproject_save_files: Support nested directories in dist-info
20b2b6
20b2b6
* Tue Mar 22 2022 Miro Hrončok <mhroncok@redhat.com> - 1.0.1-1
20b2b6
- Prefix paths of intermediate files (such as %%{pyproject_files}) with NVRA
20b2b6
20b2b6
* Tue Mar 01 2022 Miro Hrončok <mhroncok@redhat.com> - 1.0.0-1
20b2b6
- Release final version 1.0.0
20b2b6
20b2b6
* Mon Feb 07 2022 Lumír Balhar <lbalhar@redhat.com> - 1.0.0~rc2-1
20b2b6
- Updated compatibility with tox4
20b2b6
7ef706
* Tue Jan 25 2022 Miro Hrončok <mhroncok@redhat.com> - 1.0.0~rc1-1
7ef706
- Release version 1.0.0, first release candidate
7ef706
7ef706
* Mon Jan 24 2022 Miro Hrončok <mhroncok@redhat.com> - 0-55
7ef706
- %%pyproject_buildrequires: Generate BuildRequires for this package
7ef706
  This package is already installed, but this way, the resulting SRPM explicitly BuildRequires it
7ef706
7ef706
* Wed Jan 19 2022 Karolina Surma <ksurma@redhat.com> - 0-54
7ef706
- Include compressed manpages to the package if flag '+auto' is provided to %%pyproject_save_files
7ef706
7ef706
* Fri Jan 14 2022 Miro Hrončok <mhroncok@redhat.com> - 0-53
7ef706
- %%pyproject_buildrequires: Make -r (include runtime) the default, use -R to opt-out
7ef706
7ef706
* Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-52
7ef706
- Handle legacy version specifiers that would previously raise exceptions.
7ef706
7ef706
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 0-51
7ef706
- Define provisional %%pyproject_build_lib
7ef706
7ef706
* Mon Nov 1 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-50
7ef706
- Improve handling of > operator, preventing post-release from satisfying most rpm requirements
7ef706
- Improve handling of < operator, preventing pre-release from satisfying rpm requirement
7ef706
- Improve handling of != operator with prefix matching, preventing pre-release from satisfying rpm requirements
7ef706
7ef706
* Tue Oct 19 2021 Karolina Surma <ksurma@redhat.com> - 0-49
7ef706
- %%pyproject_save_files: Save %%_pyproject_modules file with importable module names
7ef706
- Introduce %%pyproject_check_import which passes %%_pyproject_modules to %%py3_check_import
7ef706
- Introduce -t, -e filtering options to %%pyproject_check_import
7ef706
7ef706
* Sat Oct 16 2021 Miro Hrončok <mhroncok@redhat.com> - 0-48
7ef706
- %%pyproject_buildrequires: Accept installed pre-releases for all requirements
7ef706
7ef706
* Thu Sep 09 2021 Miro Hrončok <mhroncok@redhat.com> - 0-47
7ef706
- %%pyproject_save_files: Expand the namespace error message, also display it with /
7ef706
- %%pyproject_save_files: Add a workaround error for spaces and [brackets]
7ef706
7ef706
* Fri Jul 23 2021 Miro Hrončok <miro@hroncok.cz> - 0-46
7ef706
- %%pyproject_buildrequires now fails when it encounters an invalid requirement
7ef706
- Rename %%_pyproject_ghost_distinfo and %%_pyproject_record to indicate they are private
7ef706
- Automatically detect LICENSE files and mark them with %%license macro
7ef706
7ef706
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0-45
7ef706
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
7ef706
7ef706
* Fri Jul 09 2021 Python Maint <python-maint@redhat.com> - 0-44
7ef706
- Escape weird paths generated by %%pyproject_save_files
7ef706
- Support x.* versions in %%pyproject_buildrequires
7ef706
- %%pyproject_buildrequires fallbacks to setuptools only if setup.py exists
7ef706
- Explicitly require the "basic" Python RPM macros
7ef706
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
7ef706
  Related: rhbz#1991688
7ef706
7ef706
* Thu Jul 01 2021 Tomas Hrnciar <thrnciar@redhat.com> - 0-43
7ef706
- Generate BuildRequires from file
7ef706
7ef706
* Tue Jun 29 2021 Miro Hrončok <mhroncok@redhat.com> - 0-42
7ef706
- Don't accidentally treat "~= X.0" requirement as "~= X"
7ef706
- Fixes rhzb#1977060
7ef706
7ef706
* Mon Jun 28 2021 Miro Hrončok <mhroncok@redhat.com> - 0-41
7ef706
- Don't leak %%{_pyproject_builddir} to pytest collection
7ef706
7ef706
* Thu May 27 2021 Miro Hrončok <mhroncok@redhat.com> - 0-40
7ef706
- Don't leak $TMPDIR outside of pyproject macros
7ef706
- Set %%_pyproject_wheeldir and %%_pyproject_builddir relative to the source tree, not $PWD
7ef706
7ef706
* Thu Apr 22 2021 Miro Hrončok <mhroncok@redhat.com> - 0-39.2
7ef706
- Handle tox provision (tox.requires / tox.minversion)
7ef706
- Generate BuildRequires on extras in lower case
7ef706
- Fixes: rhbz#1947074
7ef706
7ef706
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0-39.1
7ef706
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
7ef706
7ef706
* Mon Mar 08 2021 Charalampos Stratakis <cstratak@redhat.com> - 0-38.1
7ef706
- Disable tests on RHEL9 to remove tox dependency
7ef706
7ef706
* Sun Feb 07 2021 Miro Hrončok <mhroncok@redhat.com> - 0-38
7ef706
- Include nested __pycache__ directories in %%pyproject_save_files
7ef706
- Fixes: rhbz#1925963
7ef706
7ef706
* Tue Feb 02 2021 Miro Hrončok <mhroncok@redhat.com> - 0-37
7ef706
- Remove support for Python 3.7 from %%pyproject_buildrequires
7ef706
- Generate python3dist(toml) BR with pyproject.toml earlier to avoid extra install round
7ef706
- Generate python3dist(setutpools/wheel) BR without pyproject.toml earlier as well
7ef706
7ef706
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0-36
7ef706
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
7ef706
7ef706
* Fri Jan 15 2021 Miro Hrončok <mhroncok@redhat.com> - 0-35
7ef706
- Update the description of the package to match the new README content
7ef706
7ef706
* Fri Dec 04 2020 Miro Hrončok <miro@hroncok.cz> - 0-34
7ef706
- List all files in %%pyproject_files explicitly to avoid duplicate %%lang entries
7ef706
- If you amend the installed files after %%pyproject_install, %%pyproject_files might break
7ef706
7ef706
* Fri Nov 27 2020 Miro Hrončok <mhroncok@redhat.com> - 0-33
7ef706
- Pass PYTHONDONTWRITEBYTECODE=1 to %%tox to avoid packaged PYTEST bytecode
7ef706
7ef706
* Tue Nov 03 2020 Miro Hrončok <mhroncok@redhat.com> - 0-32
7ef706
- Allow multiple -e in %%pyproject_buildrequires
7ef706
- Fixes: rhbz#1886509
7ef706
7ef706
* Mon Oct 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-31
7ef706
- Support PEP 517 list based backend-path
7ef706
7ef706
* Tue Sep 29 2020 Lumír Balhar <lbalhar@redhat.com> - 0-30
7ef706
- Process RECORD files in %%pyproject_install and remove them
7ef706
- Support the extras configuration option of tox in %%pyproject_buildrequires -t
7ef706
- Support multiple -x options for %%pyproject_buildrequires
7ef706
- Fixes: rhbz#1877977
7ef706
- Fixes: rhbz#1877978
7ef706
7ef706
* Wed Sep 23 2020 Miro Hrončok <mhroncok@redhat.com> - 0-29
7ef706
- Check the requirements after installing "requires_for_build_wheel"
7ef706
- If not checked, installing runtime requirements might fail
7ef706
7ef706
* Tue Sep 08 2020 Gordon Messmer <gordon.messmer@gmail.com> - 0-28
7ef706
- Support more Python version specifiers in generated BuildRequires
7ef706
- This adds support for the '~=' operator and wildcards
7ef706
7ef706
* Fri Sep 04 2020 Miro Hrončok <miro@hroncok.cz> - 0-27
7ef706
- Make code in $PWD importable from %%pyproject_buildrequires
7ef706
- Only require toml for projects with pyproject.toml
7ef706
- Remove a no longer useful warning for unrecognized files in %%pyproject_save_files
7ef706
7ef706
* Mon Aug 24 2020 Tomas Hrnciar <thrnciar@redhat.com> - 0-26
7ef706
- Implement automatic detection of %%lang files in %%pyproject_save_files
7ef706
  and mark them with %%lang in filelist
7ef706
7ef706
* Fri Aug 14 2020 Miro Hrončok <mhroncok@redhat.com> - 0-25
7ef706
- Handle Python Extras in %%pyproject_buildrequires on Fedora 33+
7ef706
7ef706
* Tue Aug 11 2020 Miro Hrončok <mhroncok@redhat.com> - 0-24
7ef706
- Allow multiple, comma-separated extras in %%pyproject_buildrequires -x
7ef706
7ef706
* Mon Aug 10 2020 Lumír Balhar <lbalhar@redhat.com> - 0-23
7ef706
- Make macros more universal for alternative Python stacks
7ef706
7ef706
* Thu Aug 06 2020 Tomas Hrnciar <thrnciar@redhat.com> - 0-22
7ef706
- Change %%pyproject_save_files +bindir argument to +auto
7ef706
  to list all unclassified files in filelist
7ef706
7ef706
* Tue Aug 04 2020 Miro Hrončok <mhroncok@redhat.com> - 0-21
7ef706
- Actually implement %%pyproject_extras_subpkg
7ef706
7ef706
* Wed Jul 29 2020 Miro Hrončok <mhroncok@redhat.com> - 0-20
7ef706
- Implement %%pyproject_extras_subpkg
7ef706
7ef706
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0-19
7ef706
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
7ef706
7ef706
* Thu Jul 16 2020 Miro Hrončok <mhroncok@redhat.com> - 0-18
7ef706
- %%pyproject_buildrequires -x (extras requires for tests) now implies -r
7ef706
  (runtime requires) instead of erroring without it for better UX.
7ef706
7ef706
* Wed Jul 15 2020 Miro Hrončok <mhroncok@redhat.com> - 0-17
7ef706
- Set HOSTNAME to prevent tox 3.17+ from a DNS query
7ef706
- Fixes rhbz#1856356
7ef706
7ef706
* Fri Jun 19 2020 Miro Hrončok <mhroncok@redhat.com> - 0-16
7ef706
- Switch from upstream deprecated pytoml to toml
7ef706
7ef706
* Thu May 07 2020 Tomas Hrnciar <thrnciar@redhat.com> - 0-15
7ef706
- Adapt %%pyproject_install not to create a PEP 610 direct_url.json file
7ef706
7ef706
* Wed Apr 15 2020 Patrik Kopkan <pkopkan@redhat.com> - 0-14
7ef706
- Add %%pyproject_save_file macro for generating file section
7ef706
- Handle extracting debuginfo from extension modules (#1806625)
7ef706
7ef706
* Mon Mar 02 2020 Miro Hrončok <mhroncok@redhat.com> - 0-13
7ef706
- Tox dependency generator: Handle deps read in from a text file (#1808601)
7ef706
7ef706
* Wed Feb 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-12
7ef706
- Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta
7ef706
- Properly handle backends with colon
7ef706
- Preserve existing flags in shebangs of Python files in /usr/bin
7ef706
7ef706
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0-11
7ef706
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
7ef706
7ef706
* Fri Nov 15 2019 Patrik Kopkan <pkopkan@redhat.com> - 0-10
7ef706
- Install wheel in '$PWD/pyproject-macros-wheeldir' to have more explicit path from which we install.
7ef706
- The path can be changed by redefining %%_pyproject_wheeldir.
7ef706
7ef706
* Wed Nov 13 2019 Anna Khaitovich <akhaitov@redhat.com> - 0-9
7ef706
- Remove stray __pycache__ directory from /usr/bin when running %%pyproject_install
7ef706
7ef706
* Fri Oct 25 2019 Miro Hrončok <mhroncok@redhat.com> - 0-8
7ef706
- When tox fails, print tox output before failing
7ef706
7ef706
* Tue Oct 08 2019 Miro Hrončok <mhroncok@redhat.com> - 0-7
7ef706
- Move a verbose line of %%pyproject_buildrequires from stdout to stderr
7ef706
7ef706
* Fri Jul 26 2019 Petr Viktorin <pviktori@redhat.com> - 0-6
7ef706
- Use importlib_metadata rather than pip freeze
7ef706
7ef706
* Fri Jul 26 2019 Miro Hrončok <mhroncok@redhat.com> - 0-5
7ef706
- Allow to fetch test dependencies from tox
7ef706
- Add %%tox macro to invoke tests
7ef706
7ef706
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0-4
7ef706
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
7ef706
7ef706
* Tue Jul 02 2019 Miro Hrončok <mhroncok@redhat.com> - 0-3
7ef706
- Add %%pyproject_buildrequires
7ef706
7ef706
* Tue Jul 02 2019 Miro Hrončok <mhroncok@redhat.com> - 0-2
7ef706
- Fix shell syntax errors in %%pyproject_install
7ef706
- Drop PATH warning in %%pyproject_install
7ef706
7ef706
* Fri Jun 28 2019 Patrik Kopkan <pkopkan@redhat.com> - 0-1
7ef706
- created package