Compare commits

...

22 Commits

Author SHA1 Message Date
Miro Hrončok 345517d213 Run tests with Python 3.12 in %check (RHEL 9 specific)
Also, add a Python 3.12 CI job (isort_c9s already contains that as well).

Resolves: RHEL-22803
2024-01-26 11:48:54 +01:00
Miro Hrončok 29eb590e45 Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion} 2024-01-26 11:36:24 +01:00
Miro Hrončok 188276960b CI: Skip httpbin %tox on F40+ 2024-01-26 11:19:37 +01:00
Miro Hrončok f8b0e925e8 Fix %pyproject_buildrequires -w when the build backend is already installed and pip isn't
Fixes: https://bugzilla.redhat.com/2169855
2024-01-26 11:19:37 +01:00
Miro Hrončok 9afde6e68e Show a better error message when %pyproject_install finds no wheel
Fixes: https://bugzilla.redhat.com/2242452
2024-01-26 11:19:37 +01:00
Miro Hrončok b5c55d6167 Prevent incorrect usage of %pyproject_buildrequires -R with -x/-e/-t
Fixes: https://bugzilla.redhat.com/2244282
2024-01-26 11:19:37 +01:00
Miro Hrončok d62ed44b6e CI: Use DNF 4 in mock to workaround dnf5#1084
mock-core-configs-39.3 switched the package manager for Fedora 40 to dnf5
  https://fedoraproject.org/wiki/Changes/BuildWithDNF5

dnf5 builddep cannot handle BuildRequires with square brackets,
e.g. with Python extras, leading to errors like:

  No match for argument: python3dist(setuptools-scm[toml]) >= 5
  No match for argument: python3dist(raven[flask])
  No match for argument: python3dist(ini2toml[lite]) >= 0.9

This is reported: https://github.com/rpm-software-management/dnf5/issues/1084

Until it is fixed, we explicitly use the "dnf" (i.e. DNF 4) package manager in mock,
even on Fedora 40+.
2024-01-26 11:19:37 +01:00
Miro Hrončok 22918dd2a6 Add the -l/-L flag to %pyproject_save_files
- The -l flag can be used to assert at least 1 License-File was detected
- The -L flag explicitly disables this check (which remains the default)

Co-Authored-By: Maxwell G <maxwell@gtmx.me>
2024-01-26 11:19:37 +01:00
Miro Hrončok 7f8db987f3 Fix a typo in an error message 2024-01-26 11:19:37 +01:00
Miro Hrončok 7e0207e048 Fix a typo in the latest changelog entry 2024-01-26 11:19:37 +01:00
Miro Hrončok fa2855f6ce Fix handling of tox 4 provision without tox minversion
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2240590

The added test actually blows up without the fix with both tox 4 or tox 3,
so perhaps this bug also existed with tox 3.
2024-01-26 11:19:37 +01:00
Miro Hrončok d95890489a Communicate loudly that this does not work with old RPM
I have seen several folks building this package in a RHEL 8 environment.
This won't prevent them doing so, but at least they will be forced to make changes,
acknowledging the fact that what they are doing has consequences.
2024-01-26 11:19:37 +01:00
Karolina Surma 47cfbcf6e3 Add %_pyproject_check_import_allow_no_modules
Macro which allows to pass the import check even if no Python modules
are detected in the package.
Only to be used in the automated environments.

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
2024-01-26 11:19:35 +01:00
Carl George 39dc109d06 Fix PEP number typo 2024-01-26 11:16:14 +01:00
Miro Hrončok 3f1dd1c441 Use %rpmversion to check if we are on RPM 4.19+ 2024-01-26 11:15:16 +01:00
Miro Hrončok e7332c16ab CI: Don't treat DeprecationWarnings in setuptools_scm's %check as errors 2024-01-26 11:15:16 +01:00
Miro Hrončok a0c94e93cf CI: Update setuptools to make it build with Python 3.12
This still works on Fedora 37/38. EL 9 uses a different setuptools version for tests.
2024-01-26 11:15:16 +01:00
Miro Hrončok ff6ed86bff CI: Update poetry-core to workaround a weird FTBFS on Fedora 39+
This still builds on previous Fedoras and EPEL 9.
2024-01-26 11:15:16 +01:00
Miro Hrončok a594a93c9b CI: Update ipykernel to a version that no longer uses the imp module
This still works on Fedora 37 and 38. The c9s package skips this test.
2024-01-26 11:15:16 +01:00
Miro Hrončok d24b6f418d CI: Apply a FTBFS fix from Fedora 39 to the virtualenv spec 2024-01-26 11:15:16 +01:00
Miro Hrončok d578e3b8dc CI: Make pytest build on Fedora 37 to 39 as well as EPEL 9 2024-01-26 11:15:16 +01:00
Miro Hrončok 31f99e7ad0 CI: Run mock in verbose mode to see the logs 2024-01-26 11:15:16 +01:00
32 changed files with 331 additions and 82 deletions

View File

@ -288,6 +288,12 @@ However, in Fedora packages, always list executables explicitly to avoid uninten
and language (`*.mo`) files with `%lang` macro and appropriate language code. and language (`*.mo`) files with `%lang` macro and appropriate language code.
Only license files declared via [PEP 639] `License-File` field are detected. Only license files declared via [PEP 639] `License-File` field are detected.
[PEP 639] is still a draft and can be changed in the future. [PEP 639] is still a draft and can be changed in the future.
It is possible to use the `-l` flag to declare that a missing license should
terminate the build or `-L` (the default) to explicitly disable this check.
Packagers are encouraged to use the `-l` flag when the `%license` file is not manually listed in `%files`
to avoid accidentally losing the file in a future version.
When the `%license` file is manually listed in `%files`,
packagers can use the `-L` flag to ensure future compatibility in case the `-l` behavior eventually becomes a default.
Note that `%pyproject_save_files` uses data from the [RECORD file](https://www.python.org/dev/peps/pep-0627/). Note that `%pyproject_save_files` uses data from the [RECORD file](https://www.python.org/dev/peps/pep-0627/).
If you wish to rename, remove or otherwise change the installed files of a package If you wish to rename, remove or otherwise change the installed files of a package
@ -342,6 +348,12 @@ The `%pyproject_check_import` macro also accepts positional arguments with
additional qualified module names to check, useful for example if some modules are installed manually. additional qualified module names to check, useful for example if some modules are installed manually.
Note that filtering by `-t`/`-e` also applies to the positional arguments. Note that filtering by `-t`/`-e` also applies to the positional arguments.
Another macro, `%_pyproject_check_import_allow_no_modules` allows to pass the import check,
even if no Python modules are detected in the package.
This may be a valid case for packages containing e.g. typing stubs.
Don't use this macro in Fedora packages.
It's only intended to be used in automated build environments such as Copr.
Generating Extras subpackages Generating Extras subpackages
----------------------------- -----------------------------

View File

@ -1,5 +1,9 @@
# This is a backward-compatible suffix used in all pyproject-rpm-macros directories
# For the main Python it's empty, for all others it's "-3.X"
%_pyproject_files_pkgversion %{expr:"%{python3_pkgversion}" != "3" ? "-%{python3_pkgversion}" : ""}
# This is a directory where wheels are stored and installed from, absolute # This is a directory where wheels are stored and installed from, absolute
%_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir %_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir%{_pyproject_files_pkgversion}
# This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD # This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD
# For proper debugsource packages, we create TMPDIR within PWD # For proper debugsource packages, we create TMPDIR within PWD
@ -8,12 +12,12 @@
# This will be used in debugsource package paths (applies to extension modules only) # This will be used in debugsource package paths (applies to extension modules only)
# NB: pytest collects tests from here if not hidden # NB: pytest collects tests from here if not hidden
# https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs # https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs
%_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir %_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir%{_pyproject_files_pkgversion}
# We prefix all created files with this value to make them unique # We prefix all created files with this value to make them unique
# Ideally, we would put them into %%{buildsubdir}, but that value changes during the spec # 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
%_pyproject_files_prefix %{name}-%{version}-%{release}.%{_arch} %_pyproject_files_prefix %{name}-%{version}-%{release}.%{_arch}%{_pyproject_files_pkgversion}
%pyproject_files %{_builddir}/%{_pyproject_files_prefix}-pyproject-files %pyproject_files %{_builddir}/%{_pyproject_files_prefix}-pyproject-files
%_pyproject_modules %{_builddir}/%{_pyproject_files_prefix}-pyproject-modules %_pyproject_modules %{_builddir}/%{_pyproject_files_prefix}-pyproject-modules
@ -65,6 +69,10 @@ echo $(IFS=:; echo "${pyproject_build_lib[*]}")
%pyproject_install() %{expand:\\\ %pyproject_install() %{expand:\\\
specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/') specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/')
if [ -z $specifier ]; then
echo 'ERROR: %%%%pyproject_install found no wheel in %%%%{_pyproject_wheeldir} %{_pyproject_wheeldir}' >&2
exit 1
fi
TMPDIR="%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --prefix %{_prefix} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier TMPDIR="%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --prefix %{_prefix} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier
if [ -d %{buildroot}%{_bindir} ]; then if [ -d %{buildroot}%{_bindir} ]; then
%py3_shebang_fix %{buildroot}%{_bindir}/* %py3_shebang_fix %{buildroot}%{_bindir}/*
@ -106,12 +114,10 @@ fi
# Escaping an actual percentage sign in path by 8 signs has been verified in RPM 4.16 and 4.17. # Escaping an actual percentage sign in path by 8 signs has been verified in RPM 4.16 and 4.17.
# See this thread http://lists.rpm.org/pipermail/rpm-list/2021-June/002048.html # See this thread http://lists.rpm.org/pipermail/rpm-list/2021-June/002048.html
# Since RPM 4.19, 2 signs are needed instead. # Since RPM 4.19, 2 signs are needed instead. 4.18.90+ is a pre-release of RPM 4.19.
# On the CI, we build tests/escape_percentages.spec to verify the assumptions. # On the CI, we build tests/escape_percentages.spec to verify the assumptions.
# We should check RPM version here instead of Fedora/RHEL, but it's hard; %pyproject_save_files(lL) %{expand:\\\
# see https://github.com/rpm-software-management/rpm/issues/2523 %{expr:v"0%{?rpmversion}" >= v"4.18.90" ? "RPM_PERCENTAGES_COUNT=2" : "RPM_PERCENTAGES_COUNT=8" } \\
%pyproject_save_files() %{expand:\\\
%{expr:0%{?fedora} >= 39 || 0%{?rhel} >= 10 ? "RPM_PERCENTAGES_COUNT=2" : "RPM_PERCENTAGES_COUNT=8" } \\
%{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\ %{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\
--output-files "%{pyproject_files}" \\ --output-files "%{pyproject_files}" \\
--output-modules "%{_pyproject_modules}" \\ --output-modules "%{_pyproject_modules}" \\
@ -121,7 +127,7 @@ fi
--python-version "%{python3_version}" \\ --python-version "%{python3_version}" \\
--pyproject-record "%{_pyproject_record}" \\ --pyproject-record "%{_pyproject_record}" \\
--prefix "%{_prefix}" \\ --prefix "%{_prefix}" \\
%{*} %{**}
} }
# -t - Process only top-level modules # -t - Process only top-level modules
@ -135,6 +141,14 @@ fi
} }
%_pyproject_check_import_allow_no_modules(e:t) \
if [ -z "$(cat %{_pyproject_modules})" ]; then\
echo "No modules to check found, exiting check"\
else\
%pyproject_check_import %{?**}\
fi
%default_toxenv py%{python3_version_nodots} %default_toxenv py%{python3_version_nodots}
%toxenv %{default_toxenv} %toxenv %{default_toxenv}
@ -150,6 +164,9 @@ fi
%{?_package_note_flags:%_generate_package_note_file} %{?_package_note_flags:%_generate_package_note_file}
%{-R: %{-R:
%{-r:%{error:The -R and -r options are mutually exclusive}} %{-r:%{error:The -R and -r options are mutually exclusive}}
%{-x:%{error:The -R and -x options are mutually exclusive}}
%{-e:%{error:The -R and -e options are mutually exclusive}}
%{-t:%{error:The -R and -t options are mutually exclusive}}
%{-w:%{error:The -R and -w options are mutually exclusive}} %{-w:%{error:The -R and -w options are mutually exclusive}}
} }
%{-N: %{-N:

View File

@ -13,7 +13,7 @@ License: MIT
# Increment Y and reset Z when new macros or features are added # Increment Y and reset Z when new macros or features are added
# Increment Z when this is a bugfix or a cosmetic change # Increment Z when this is a bugfix or a cosmetic change
# Dropping support for EOL Fedoras is *not* considered a breaking change # Dropping support for EOL Fedoras is *not* considered a breaking change
Version: 1.9.0 Version: 1.12.0
Release: 1%{?dist} Release: 1%{?dist}
# Macro files # Macro files
@ -63,13 +63,20 @@ BuildRequires: python3dist(tox-current-env) >= 0.0.6
BuildRequires: python3dist(wheel) BuildRequires: python3dist(wheel)
BuildRequires: (python3dist(tomli) if python3 < 3.11) BuildRequires: (python3dist(tomli) if python3 < 3.11)
# RHEL 9: We also run pytest with Python 3.11 # RHEL 9: We also run pytest with Python 3.11 and 3.12
BuildRequires: python3.11dist(pytest) BuildRequires: python3.11dist(pytest)
BuildRequires: python3.11dist(pyyaml) BuildRequires: python3.11dist(pyyaml)
BuildRequires: python3.11dist(packaging) BuildRequires: python3.11dist(packaging)
BuildRequires: python3.11dist(pip) BuildRequires: python3.11dist(pip)
BuildRequires: python3.11dist(setuptools) BuildRequires: python3.11dist(setuptools)
BuildRequires: python3.11dist(wheel) BuildRequires: python3.11dist(wheel)
BuildRequires: python3.12dist(pytest)
BuildRequires: python3.12dist(pyyaml)
BuildRequires: python3.12dist(packaging)
BuildRequires: python3.12dist(pip)
BuildRequires: python3.12dist(setuptools)
BuildRequires: python3.12dist(wheel)
%endif %endif
# We build on top of those: # We build on top of those:
@ -85,6 +92,12 @@ Requires: (pyproject-srpm-macros = %{?epoch:%{epoch}:}%{version}-%{release
Requires: /usr/bin/find Requires: /usr/bin/find
Requires: /usr/bin/sed Requires: /usr/bin/sed
# This package requires the %%generate_buildrequires functionality.
# It has been introduced in RPM 4.15 (4.14.90 is the alpha of 4.15).
# What we need is rpmlib(DynamicBuildRequires), but that is impossible to (Build)Require.
Requires: (rpm-build >= 4.14.90 if rpm-build)
BuildRequires: rpm-build >= 4.14.90
%description %description
These macros allow projects that follow the Python packaging specifications These macros allow projects that follow the Python packaging specifications
to be packaged as RPMs. to be packaged as RPMs.
@ -103,6 +116,7 @@ which only work with setup.py.
%package -n pyproject-srpm-macros %package -n pyproject-srpm-macros
Summary: Minimal implementation of %%pyproject_buildrequires Summary: Minimal implementation of %%pyproject_buildrequires
Requires: (pyproject-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} if pyproject-rpm-macros) Requires: (pyproject-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} if pyproject-rpm-macros)
Requires: (rpm-build >= 4.14.90 if rpm-build)
%description -n pyproject-srpm-macros %description -n pyproject-srpm-macros
This package contains a minimal implementation of %%pyproject_buildrequires. This package contains a minimal implementation of %%pyproject_buildrequires.
@ -117,6 +131,9 @@ takes precedence.
%setup -c -T %setup -c -T
cp -p %{sources} . cp -p %{sources} .
%generate_buildrequires
# nothing to do, this is here just to assert we have that functionality
%build %build
# nothing to do, sources are not buildable # nothing to do, sources are not buildable
@ -146,7 +163,11 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%pytest -vv --doctest-modules %{?with_pytest_xdist:-n auto} %{!?with_tox_tests:-k "not tox"} %pytest -vv --doctest-modules %{?with_pytest_xdist:-n auto} %{!?with_tox_tests:-k "not tox"}
# RHEL 9 only: # RHEL 9 only:
%global __pytest %{__pytest}-3.11 %global __pytest pytest-3.11
%pytest -vv --doctest-modules -k "not tox"
# RHEL 9 only:
%global __pytest pytest-3.12
%pytest -vv --doctest-modules -k "not tox" %pytest -vv --doctest-modules -k "not tox"
# brp-compress is provided as an argument to get the right directory macro expansion # brp-compress is provided as an argument to get the right directory macro expansion
@ -173,6 +194,27 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%changelog %changelog
* Fri Jan 26 2024 Miro Hrončok <miro@hroncok.cz> - 1.12.0-1
- Namespace pyproject-rpm-macros generated text files with %%{python3_pkgversion}
- That way, a single-spec can be used to build packages for multiple Python versions
- Fixes: rhbz#2209055
* Wed Sep 27 2023 Miro Hrončok <mhroncok@redhat.com> - 1.11.0-1
- Add the -l/-L flag to %%pyproject_save_files
- The -l flag can be used to assert at least 1 License-File was detected
- The -L flag explicitly disables this check (which remains the default)
- Prevent incorrect usage of %%pyproject_buildrequires -R with -x/-e/-t
- Fixes: rhbz#2244282
- Show a better error message when %%pyproject_install finds no wheel
- Fixes: rhbz#2242452
- Fix %%pyproject_buildrequires -w when the build backend is already installed and pip isn't
- Fixes: rhbz#2169855
* Wed Sep 13 2023 Python Maint <python-maint@redhat.com> - 1.10.0-1
- Add %%_pyproject_check_import_allow_no_modules for automated environments
- Fix handling of tox 4 provision without an explicit tox minversion
- Fixes: rhbz#2240590
* Wed May 31 2023 Maxwell G <maxwell@gtmx.me> - 1.9.0-1 * Wed May 31 2023 Maxwell G <maxwell@gtmx.me> - 1.9.0-1
- Allow passing config_settings to the build backend. - Allow passing config_settings to the build backend.
@ -212,7 +254,8 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
- Use %%py3_test_envvars in %%tox when available - Use %%py3_test_envvars in %%tox when available
* Mon Sep 19 2022 Python Maint <python-maint@redhat.com> - 1.4.0-1 * Mon Sep 19 2022 Python Maint <python-maint@redhat.com> - 1.4.0-1
- %%pyproject_save_files: Support License-Files installed into the *Root License Directory* from PEP 369 - %%pyproject_save_files: Support License-Files installed into the *Root License Directory* from PEP 639
- %%pyproject_check_import: Import only the modules whose top-level names - %%pyproject_check_import: Import only the modules whose top-level names
match any of the globs provided to %%pyproject_save_files match any of the globs provided to %%pyproject_save_files

View File

@ -328,6 +328,11 @@ def generate_run_requirements_wheel(backend, requirements, wheeldir):
# Reuse the wheel from the previous round of %pyproject_buildrequires (if it exists) # Reuse the wheel from the previous round of %pyproject_buildrequires (if it exists)
wheel = find_built_wheel(wheeldir) wheel = find_built_wheel(wheeldir)
if not wheel: if not wheel:
# pip is already echoed from the macro
# but we need to explicitly restart if has not yet been installed
# see https://bugzilla.redhat.com/2169855
requirements.add('pip >= 19', source='%pyproject_buildrequires -w')
requirements.check(source='%pyproject_buildrequires -w')
import pyproject_wheel import pyproject_wheel
returncode = pyproject_wheel.build_wheel( returncode = pyproject_wheel.build_wheel(
wheeldir=wheeldir, wheeldir=wheeldir,
@ -386,7 +391,7 @@ def generate_tox_requirements(toxenv, requirements):
provision_content = provision.read() provision_content = provision.read()
if provision_content and r.returncode != 0: if provision_content and r.returncode != 0:
provision_requires = json.loads(provision_content) provision_requires = json.loads(provision_content)
if 'minversion' in provision_requires: if provision_requires.get('minversion') is not None:
requirements.add(f'tox >= {provision_requires["minversion"]}', requirements.add(f'tox >= {provision_requires["minversion"]}',
source='tox provision (minversion)') source='tox provision (minversion)')
if 'requires' in provision_requires: if 'requires' in provision_requires:

View File

@ -365,6 +365,7 @@ Run dependencies with extras and build wheel option:
setuptools: 50 setuptools: 50
wheel: 1 wheel: 1
pyyaml: 1 pyyaml: 1
pip: 20
include_runtime: true include_runtime: true
build_wheel: true build_wheel: true
extras: extras:
@ -375,6 +376,7 @@ Run dependencies with extras and build wheel option:
python3dist(wheel) python3dist(wheel)
python3dist(wheel) python3dist(wheel)
python3dist(setuptools) >= 40 python3dist(setuptools) >= 40
python3dist(pip) >= 19
python3dist(py) >= 1.5 python3dist(py) >= 1.5
python3dist(six) >= 1.10 python3dist(six) >= 1.10
python3dist(setuptools) python3dist(setuptools)
@ -589,6 +591,43 @@ tox provision satisfied:
python3dist(inst) python3dist(inst)
result: 0 result: 0
tox provision no minversion:
installed:
setuptools: 50
wheel: 1
tox: 3.5.3
tox-current-env: 0.0.6
toxenv:
- py3
setup.py: |
from setuptools import setup
setup(
name='test',
version='0.1',
)
tox.ini: |
[tox]
requires =
setuptools > 40
wheel > 2
expected:
- | # tox 3
python3dist(setuptools) >= 40.8
python3dist(wheel)
python3dist(wheel)
python3dist(tox-current-env) >= 0.0.6
python3dist(setuptools) > 40.0
python3dist(wheel) > 2.0
- | # tox 4
python3dist(setuptools) >= 40.8
python3dist(wheel)
python3dist(wheel)
python3dist(tox-current-env) >= 0.0.6
python3dist(setuptools) > 40.0
python3dist(wheel) > 2.0
python3dist(tox)
result: 0
Default build system, unmet deps in requirements file: Default build system, unmet deps in requirements file:
installed: installed:
setuptools: 50 setuptools: 50

View File

@ -345,7 +345,7 @@ def classify_paths(
} }
license_files = metadata.get_all('License-File') license_files = metadata.get_all('License-File')
license_directory = distinfo / 'licenses' # See PEP 369 "Root License Directory" license_directory = distinfo / 'licenses' # See PEP 639 "Root License Directory"
# setuptools was the first known build backend to implement License-File. # setuptools was the first known build backend to implement License-File.
# Unfortunately they don't put licenses to the license directory (yet): # Unfortunately they don't put licenses to the license directory (yet):
# https://github.com/pypa/setuptools/issues/3596 # https://github.com/pypa/setuptools/issues/3596
@ -673,7 +673,7 @@ def load_parsed_record(pyproject_record):
content = json.load(pyproject_record_file) content = json.load(pyproject_record_file)
if len(content) > 1: if len(content) > 1:
raise FileExistsError("%pyproject install has found more than one *.dist-info/RECORD file. " raise FileExistsError("%pyproject_install has found more than one *.dist-info/RECORD file. "
"Currently, %pyproject_save_files supports only one wheel → one file list mapping. " "Currently, %pyproject_save_files supports only one wheel → one file list mapping. "
"Feel free to open a bugzilla for pyproject-rpm-macros and describe your usecase.") "Feel free to open a bugzilla for pyproject-rpm-macros and describe your usecase.")
@ -693,12 +693,15 @@ def dist_metadata(buildroot, record_path):
return dist.metadata return dist.metadata
def pyproject_save_files_and_modules(buildroot, sitelib, sitearch, python_version, pyproject_record, prefix, varargs): def pyproject_save_files_and_modules(buildroot, sitelib, sitearch, python_version, pyproject_record, prefix, assert_license, varargs):
""" """
Takes arguments from the %{pyproject_save_files} macro Takes arguments from the %{pyproject_save_files} macro
Returns tuple: list of paths for the %files section and list of module names Returns tuple: list of paths for the %files section and list of module names
for the %check section for the %check section
Raises ValueError when assert_license is true and no License-File (PEP 639)
is found.
""" """
# On 32 bit architectures, sitelib equals to sitearch # On 32 bit architectures, sitelib equals to sitearch
# This saves us browsing one directory twice # This saves us browsing one directory twice
@ -710,11 +713,15 @@ def pyproject_save_files_and_modules(buildroot, sitelib, sitearch, python_versio
final_file_list = [] final_file_list = []
final_module_list = [] final_module_list = []
# we assume OK when not asserting
license_ok = not assert_license
for record_path, files in parsed_records.items(): for record_path, files in parsed_records.items():
metadata = dist_metadata(buildroot, record_path) metadata = dist_metadata(buildroot, record_path)
paths_dict = classify_paths( paths_dict = classify_paths(
record_path, files, metadata, sitedirs, python_version, prefix record_path, files, metadata, sitedirs, python_version, prefix
) )
license_ok = license_ok or bool(paths_dict["metadata"]["licenses"])
final_file_list.extend( final_file_list.extend(
generate_file_list(paths_dict, globs, include_auto) generate_file_list(paths_dict, globs, include_auto)
@ -723,6 +730,15 @@ def pyproject_save_files_and_modules(buildroot, sitelib, sitearch, python_versio
generate_module_list(paths_dict, globs) generate_module_list(paths_dict, globs)
) )
if not license_ok:
raise ValueError(
"No License-File (PEP 639) in upstream metadata found. "
"Adjust the upstream metadata "
"if the project's build backend supports PEP 639 "
"or use `%pyproject_save_files -L` "
"and include the %license file in %files manually."
)
return final_file_list, final_module_list return final_file_list, final_module_list
@ -734,6 +750,7 @@ def main(cli_args):
cli_args.python_version, cli_args.python_version,
cli_args.pyproject_record, cli_args.pyproject_record,
cli_args.prefix, cli_args.prefix,
cli_args.assert_license,
cli_args.varargs, cli_args.varargs,
) )
@ -747,7 +764,7 @@ def argparser():
prog="%pyproject_save_files", prog="%pyproject_save_files",
add_help=False, add_help=False,
# custom usage to add +auto # custom usage to add +auto
usage="%(prog)s MODULE_GLOB [MODULE_GLOB ...] [+auto]", usage="%(prog)s [-l|-L] MODULE_GLOB [MODULE_GLOB ...] [+auto]",
) )
parser.add_argument( parser.add_argument(
'--help', action='help', '--help', action='help',
@ -763,6 +780,14 @@ def argparser():
r.add_argument("--python-version", type=str, required=True, help=argparse.SUPPRESS) r.add_argument("--python-version", type=str, required=True, help=argparse.SUPPRESS)
r.add_argument("--pyproject-record", type=PosixPath, required=True, help=argparse.SUPPRESS) r.add_argument("--pyproject-record", type=PosixPath, required=True, help=argparse.SUPPRESS)
r.add_argument("--prefix", type=PosixPath, required=True, help=argparse.SUPPRESS) r.add_argument("--prefix", type=PosixPath, required=True, help=argparse.SUPPRESS)
parser.add_argument(
"-l", "--assert-license", action="store_true", default=False,
help="Fail when no License-File (PEP 639) is found.",
)
parser.add_argument(
"-L", "--no-assert-license", action="store_false", dest="assert_license",
help="Don't fail when no License-File (PEP 639) is found (the default).",
)
parser.add_argument( parser.add_argument(
"varargs", nargs="+", metavar="MODULE_GLOB", "varargs", nargs="+", metavar="MODULE_GLOB",
help="Shell-like glob matching top-level module names to save into %%{pyproject_files}", help="Shell-like glob matching top-level module names to save into %%{pyproject_files}",

View File

@ -48,7 +48,7 @@ touch 'escape_percentages/one%%version'
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files escape_percentages %pyproject_save_files -L escape_percentages
touch '%{buildroot}/two%%version' touch '%{buildroot}/two%%version'
@ -58,7 +58,7 @@ grep '/escape_percentages/one' %{pyproject_files}
%files -f %{pyproject_files} %files -f %{pyproject_files}
%if 0%{?fedora} >= 39 || 0%{?rhel} >= 10 %if v"0%{?rpmversion}" >= v"4.18.90"
/two%%version /two%%version
%else %else
/two%%%%%%%%version /two%%%%%%%%version

View File

@ -1,5 +1,7 @@
#!/usr/bin/bash -eux #!/usr/bin/bash -eux
. /etc/os-release if [ -z "${VERSION_ID-}" ] && [ -z "${NAME-}" ]; then
. /etc/os-release
fi
version=$(echo "${VERSION_ID}" | cut -d. -f1) version=$(echo "${VERSION_ID}" | cut -d. -f1)
arch="x86_64" arch="x86_64"
@ -34,6 +36,7 @@ if [ ! -f $config ]; then
cp $original $config cp $original $config
echo -e '\n\n' >> $config echo -e '\n\n' >> $config
echo -e 'config_opts["package_manager"] = "dnf"' >> $config
echo -e 'config_opts["package_manager_max_attempts"] = 10' >> $config echo -e 'config_opts["package_manager_max_attempts"] = 10' >> $config
echo -e 'config_opts["package_manager_attempt_delay"] = 60' >> $config echo -e 'config_opts["package_manager_attempt_delay"] = 60' >> $config
echo -e '\n\nconfig_opts[f"{config_opts.package_manager}.conf"] += """' >> $config echo -e '\n\nconfig_opts[f"{config_opts.package_manager}.conf"] += """' >> $config
@ -59,8 +62,8 @@ rpmbuild -bs --define '_sourcedir .' ${pkgname}.spec
# build the SRPM in mock # build the SRPM in mock
res=0 res=0
mock --isolation=simple -r $config --enablerepo="$repos" init mock --verbose --isolation=simple -r $config --enablerepo="$repos" init
mock --isolation=simple -r $config --enablerepo="$repos" "$@" ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm || res=$? mock --verbose --isolation=simple -r $config --enablerepo="$repos" "$@" ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm || res=$?
# move the results to the artifacts directory, so we can examine them # move the results to the artifacts directory, so we can examine them
artifacts=${TEST_ARTIFACTS:-/tmp/artifacts} artifacts=${TEST_ARTIFACTS:-/tmp/artifacts}

View File

@ -33,7 +33,7 @@ Building this tests that lang files are marked with %%lang in filelist.
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files printrun +auto %pyproject_save_files -l printrun +auto
%check %check
@ -52,4 +52,3 @@ grep -E '/printrun/__pycache__$' %{pyproject_files}
%files -f %{pyproject_files} %files -f %{pyproject_files}
%doc README* %doc README*
%license COPYING

View File

@ -42,7 +42,7 @@ sed -Ei "s/(, )?'pytest-runner'//" setup.py
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files distroinfo %pyproject_save_files -l distroinfo
%check %check
@ -52,4 +52,3 @@ sed -Ei "s/(, )?'pytest-runner'//" setup.py
%files -n python3-distroinfo -f %{pyproject_files} %files -n python3-distroinfo -f %{pyproject_files}
%doc README.rst AUTHORS %doc README.rst AUTHORS
%license LICENSE

View File

@ -40,7 +40,7 @@ find -name "*.po" | xargs rm -f
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files django %pyproject_save_files -l django
%check %check
@ -56,6 +56,5 @@ diff tested.lang expected.lang
%files -n python3-django -f %{pyproject_files} %files -n python3-django -f %{pyproject_files}
%doc README.rst %doc README.rst
%license LICENSE
%{_bindir}/django-admin %{_bindir}/django-admin
%{_bindir}/django-admin.py %{_bindir}/django-admin.py

View File

@ -55,7 +55,8 @@ sed -i \
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files lexicon # the license is not marked as License-File by poetry-core, hence -L
%pyproject_save_files -L lexicon
%check %check

View File

@ -38,7 +38,8 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files entrypoints # the license is not marked as License-File, hence -L
%pyproject_save_files entrypoints -L
%check %check

View File

@ -42,7 +42,13 @@ cd ..
%install %install
%pyproject_install %pyproject_install
# there is no license file marked as License-File, hence not using -l
%pyproject_save_files flit_core %pyproject_save_files flit_core
%check
# internal check for our macros, we assume there is no license
grep -F %%license %{pyproject_files} && exit 1 || true
%files -n python3-flit-core -f %{pyproject_files} %files -n python3-flit-core -f %{pyproject_files}

View File

@ -12,7 +12,10 @@ BuildRequires: pyproject-rpm-macros
%global _description %{expand: %global _description %{expand:
Test that manpages are correctly processed by %%pyproject_save_files '*' +auto.} Test that manpages are correctly processed by %%%%%%%%pyproject_save_files '*' +auto.
Run %%%%%%%%_pyproject_check_import_allow_no_modules twice
- exclude all modules and test the check still passes thanks to -M option
- regression test: test that check imports all modules even if -M option is set}
%description %_description %description %_description
@ -37,14 +40,40 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files '*' +auto %pyproject_save_files -l '*' +auto
%check %check
# Internal check for our macros, assert the behavior of the import check macros
# Both of the macros should succeed
%pyproject_check_import %pyproject_check_import
%_pyproject_check_import_allow_no_modules
(%{pyproject_check_import}) 2>pyproject_check_import.stderr
(%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr
# Modules were found, stderrs should include getmac.getmac
grep '^Check import: getmac\.getmac$' pyproject_check_import.stderr
grep '^Check import: getmac\.getmac$' _pyproject_check_import_allow_no_modules.stderr
# Now let's pretend no modules were found at all
echo -e '' > %{_pyproject_modules}
# This should fail
(%{pyproject_check_import}) && exit 1 || true
# This should succeed and say something about no modules found
%{_pyproject_check_import_allow_no_modules}
(%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr
grep '\bNo modules to check found\b' _pyproject_check_import_allow_no_modules.stderr
# We want to ensure the rest of the %%check section is still executed
# (To avoid a temptation to call `exit 0` from %%_pyproject_check_import_allow_no_modules)
# We'll touch a marker file here and assert its presence in %%files
touch %{buildroot}/check-completed-entirely
# Internal check for our macros, assert there is a manpage: # Internal check for our macros, assert there is a manpage:
test -f %{buildroot}%{_mandir}/man1/getmac.1* test -f %{buildroot}%{_mandir}/man1/getmac.1*
%files -n python3-getmac -f %{pyproject_files} %files -n python3-getmac -f %{pyproject_files}
/check-completed-entirely

View File

@ -56,12 +56,15 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files httpbin %pyproject_save_files -l httpbin
%if %{with tests} %if %{with tests}
%check %check
%if 0%{?fedora} < 40 && 0%{?rhel} < 10
# this version of httpbin is not compatible with werkzeug 3+
%tox %tox
%endif
# Internal check for our macros # Internal check for our macros
# The runtime dependencies contain raven[flask], we assert we got them. # The runtime dependencies contain raven[flask], we assert we got them.
@ -72,4 +75,3 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1
%files -n python3-httpbin -f %{pyproject_files} %files -n python3-httpbin -f %{pyproject_files}
%doc README* %doc README*
%license LICENSE*

View File

@ -1,5 +1,5 @@
Name: python-ipykernel Name: python-ipykernel
Version: 5.2.1 Version: 6.11.0
Release: 0%{?dist} Release: 0%{?dist}
Summary: IPython Kernel for Jupyter Summary: IPython Kernel for Jupyter
License: BSD License: BSD
@ -11,6 +11,9 @@ BuildArch: noarch
BuildRequires: pyproject-rpm-macros BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel BuildRequires: python3-devel
# some of the nested modules import from this, but upstream does not declare the dependency
BuildRequires: python3-ipyparallel
%description %description
This package contains data files. This package contains data files.
Building this tests that data files are not listed when +auto is not used Building this tests that data files are not listed when +auto is not used
@ -31,11 +34,9 @@ Summary: %{summary}
%prep %prep
%autosetup -p1 -n ipykernel-%{version} %autosetup -p1 -n ipykernel-%{version}
# Add dependency on IPython genutils # Remove the dependency on debugpy.
# https://github.com/ipython/ipykernel/pull/756 # See https://github.com/ipython/ipykernel/pull/767
# Patch does not apply, so we dirty-sed it in sed -i '/"debugpy/d' pyproject.toml setup.py
sed -i 's/install_requires=\[/install_requires=["ipython_genutils",/' setup.py
%generate_buildrequires %generate_buildrequires
%pyproject_buildrequires -r %pyproject_buildrequires -r
@ -45,12 +46,11 @@ sed -i 's/install_requires=\[/install_requires=["ipython_genutils",/' setup.py
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files 'ipykernel*' +auto %pyproject_save_files -l 'ipykernel*' +auto
%check %check
%pyproject_check_import -e '*.test*' -e 'ipykernel.gui*' -e 'ipykernel.pylab.backend_inline' %pyproject_check_import -e '*.test*' -e 'ipykernel.gui*' -e 'ipykernel.pylab.*' -e 'ipykernel.trio*'
%files -n python3-ipykernel -f %{pyproject_files} %files -n python3-ipykernel -f %{pyproject_files}
%license COPYING.md
%doc README.md %doc README.md

View File

@ -9,7 +9,6 @@ License: MIT
URL: https://github.com/timothycrosley/%{modname} URL: https://github.com/timothycrosley/%{modname}
Source0: %{url}/archive/%{version}-2/%{modname}-%{version}-2.tar.gz Source0: %{url}/archive/%{version}-2/%{modname}-%{version}-2.tar.gz
BuildArch: noarch BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: pyproject-rpm-macros BuildRequires: pyproject-rpm-macros
%description %description
@ -18,7 +17,7 @@ Building this tests that executables are not listed when +auto is not used
with %%pyproject_save_files. with %%pyproject_save_files.
This package also uses %%{python3_pkgversion} in name and has a very limited This package also uses %%{python3_pkgversion} in name and has a very limited
set of dependencies -- allows to set a different value for it in the CI. set of dependencies -- allows to set a different value for it repeatedly.
%package -n python%{python3_pkgversion}-%{modname} %package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary} Summary: %{summary}
@ -26,6 +25,24 @@ Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname} %description -n python%{python3_pkgversion}-%{modname}
%{summary}. %{summary}.
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname}
%{summary}.
%global python3_pkgversion 3.12
%package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname}
%{summary}.
%global python3_pkgversion 3
%endif
%prep %prep
%autosetup -n %{modname}-%{version}-2 %autosetup -n %{modname}-%{version}-2
@ -33,15 +50,40 @@ Summary: %{summary}
%generate_buildrequires %generate_buildrequires
%pyproject_buildrequires %pyproject_buildrequires
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_buildrequires
%global python3_pkgversion 3.12
%pyproject_buildrequires
%global python3_pkgversion 3
%endif
%build %build
%pyproject_wheel %pyproject_wheel
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_wheel
%global python3_pkgversion 3.12
%pyproject_wheel
%global python3_pkgversion 3
%endif
%install %install
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_install %pyproject_install
%pyproject_save_files isort %pyproject_save_files -l isort
%global python3_pkgversion 3.12
%pyproject_install
%pyproject_save_files -l isort
%global python3_pkgversion 3
%endif
# we keep this one last so /usr/bin/isort is installed with python3 shebang
%pyproject_install
%pyproject_save_files -l isort
%check %check
@ -52,8 +94,32 @@ test -d %{buildroot}%{python3_sitelib}/%{modname}-%{version}.dist-info/
# Internal check that executables are not present when +auto was not used with %%pyproject_save_files # Internal check that executables are not present when +auto was not used with %%pyproject_save_files
grep -F %{_bindir}/%{modname} %{pyproject_files} && exit 1 || true grep -F %{_bindir}/%{modname} %{pyproject_files} && exit 1 || true
%if 0%{?rhel} == 9
# Internal check that correct versions are in correct %%{pyproject_files}s
diff %{pyproject_files} <(grep -F python3.9/site-packages %{pyproject_files})
%global python3_pkgversion 3.11
test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}/
test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}-%{version}.dist-info/
diff %{pyproject_files} <(grep -F python3.11/site-packages %{pyproject_files})
%global python3_pkgversion 3.12
test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}/
test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}-%{version}.dist-info/
diff %{pyproject_files} <(grep -F python3.12/site-packages %{pyproject_files})
%global python3_pkgversion 3
%endif
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files} %files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md %doc README.rst *.md
%license LICENSE
%{_bindir}/%{modname} %{_bindir}/%{modname}
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md
%global python3_pkgversion 3.12
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md
%global python3_pkgversion 3
%endif

View File

@ -61,7 +61,7 @@ PYTHONPATH=%{pyproject_build_lib} %{python3} -c 'import _ldap'
%install %install
%pyproject_install %pyproject_install
# We can pass multiple globs # We can pass multiple globs
%pyproject_save_files 'ldap*' '*ldap' %pyproject_save_files -l 'ldap*' '*ldap'
%check %check
@ -104,7 +104,6 @@ test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/build/lib.%{python
%files -n python3-ldap -f %{pyproject_files} %files -n python3-ldap -f %{pyproject_files}
%license LICENCE
%doc CHANGES README TODO Demo %doc CHANGES README TODO Demo
# Explicitly listed files can be combined with automation # Explicitly listed files can be combined with automation
%pycached %{python3_sitearch}/ldif.py %pycached %{python3_sitearch}/ldif.py

View File

@ -26,7 +26,6 @@ Summary: %{summary}
# In this spec, we put %%files early to test it still works # In this spec, we put %%files early to test it still works
%files -n python3-markupsafe -f %{pyproject_files} %files -n python3-markupsafe -f %{pyproject_files}
%license LICENSE.rst
%doc CHANGES.rst README.rst %doc CHANGES.rst README.rst
@ -54,7 +53,7 @@ sed -Ei 's/sphinx\.git@([0-9a-f]+)/sphinx.git@\1#egg=sphinx/' requirements/docs.
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files markupsafe %pyproject_save_files -l markupsafe
%check %check

View File

@ -46,7 +46,7 @@ Summary: %summary
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files mistune %pyproject_save_files -l mistune
%check %check
@ -61,4 +61,3 @@ test -f %{buildroot}%{python3_sitearch}/mistune.cpython-*.so
%files -n python%{python3_pkgversion}-mistune -f %{pyproject_files} %files -n python%{python3_pkgversion}-mistune -f %{pyproject_files}
%doc README.rst %doc README.rst
%license LICENSE

View File

@ -45,7 +45,7 @@ sed -i '/mock/d' tests.requires
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files %{pypi_name} %pyproject_save_files -l %{pypi_name}
%check %check
@ -54,4 +54,3 @@ sed -i '/mock/d' tests.requires
%files -n python3-%{pypi_name} -f %{pyproject_files} %files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.* %doc README.*
%license COPYING

View File

@ -43,7 +43,7 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
# There are no executables, but we are allowed to pass +auto anyway # There are no executables, but we are allowed to pass +auto anyway
%pyproject_save_files pluggy +auto %pyproject_save_files pluggy +auto -l
%check %check
@ -52,4 +52,3 @@ Summary: %{summary}
%files -n python3-%{pypi_name} -f %{pyproject_files} %files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst %doc README.rst
%license LICENSE

View File

@ -1,5 +1,5 @@
Name: python-poetry-core Name: python-poetry-core
Version: 1.0.0 Version: 1.1.0
Release: 0%{?dist} Release: 0%{?dist}
Summary: Poetry PEP 517 Build Backend Summary: Poetry PEP 517 Build Backend
@ -37,8 +37,11 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files poetry # the license is not marked as License-File by poetry-core, hence -L
%pyproject_save_files -L poetry
# internal check for our macros, -l must fail:
%pyproject_save_files -l poetry && exit 1 || true
%files -n python3-poetry-core -f %{pyproject_files} %files -n python3-poetry-core -f %{pyproject_files}
%doc README.md %doc README.md

View File

@ -1,6 +1,6 @@
%global pypi_name pytest %global pypi_name pytest
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 6.2.5 Version: 7.1.3
Release: 0%{?dist} Release: 0%{?dist}
Summary: Simple powerful testing with Python Summary: Simple powerful testing with Python
License: MIT License: MIT
@ -40,6 +40,8 @@ sed -E -i '/mock|nose/d' setup.cfg
# internal check for our macros: insert a subprocess echo to setup.py # internal check for our macros: insert a subprocess echo to setup.py
# to ensure it's not generated as BuildRequires # to ensure it's not generated as BuildRequires
echo 'import os; os.system("echo if-this-is-generated-the-build-will-fail")' >> setup.py echo 'import os; os.system("echo if-this-is-generated-the-build-will-fail")' >> setup.py
# make this build in EPEL 9
sed -i 's/setuptools-scm\[toml\]>=6.2.3/setuptools-scm[toml]>=5/' pyproject.toml
%generate_buildrequires %generate_buildrequires
@ -52,14 +54,14 @@ echo 'import os; os.system("echo if-this-is-generated-the-build-will-fail")' >>
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files '*pytest' +auto %pyproject_save_files -l '*pytest' +auto
%check %check
%if %{with tests} %if %{with tests}
# Only run one test (which uses a test-only dependency, hypothesis) # Only run one test (which uses a test-only dependency, hypothesis)
# See how to pass options trough the macro to tox, trough tox to pytest # See how to pass options trough the macro to tox, trough tox to pytest
%tox -- -- -k metafunc %tox -- -- -k "metafunc and not test_parametrize_" -Wdefault
%else %else
%pyproject_check_import %pyproject_check_import
%endif %endif
@ -68,4 +70,3 @@ echo 'import os; os.system("echo if-this-is-generated-the-build-will-fail")' >>
%files -n python3-%{pypi_name} -f %{pyproject_files} %files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst %doc README.rst
%doc CHANGELOG.rst %doc CHANGELOG.rst
%license LICENSE

View File

@ -1,8 +1,8 @@
Name: python-setuptools Name: python-setuptools
# on the CI we test different version of setuptools on different Fedora versions # on the CI we test different version of setuptools on different Fedora versions
# don't package software like this in Fedora please # don't package software like this in Fedora please
%if 0%{?fedora} >= 37 || 0%{?rhel} >= 10 %if 0%{?fedora} || 0%{?rhel} >= 10
Version: 65.5.1 Version: 67.7.2
%else %else
Version: 59.6.0 Version: 59.6.0
%endif %endif
@ -14,8 +14,8 @@ URL: https://pypi.python.org/pypi/setuptools
Source: %{pypi_source setuptools %{version}} Source: %{pypi_source setuptools %{version}}
# Patch from Fedora proper # Patch from Fedora proper
%if 0%{?fedora} >= 37 || 0%{?rhel} >= 10 %if 0%{?fedora} || 0%{?rhel} >= 10
Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/b61d86b9659/f/Remove-optional-or-unpackaged-test-deps.patch Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/8ae9b2a777c/f/Remove-optional-or-unpackaged-test-deps.patch
%else %else
Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/6fc093d6b3d/f/0001-Remove-optional-or-unpackaged-test-deps.patch Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/6fc093d6b3d/f/0001-Remove-optional-or-unpackaged-test-deps.patch
%endif %endif
@ -54,7 +54,7 @@ Summary: %{summary}
%prep %prep
%autosetup -p1 -n setuptools-%{version} %autosetup -p1 -n setuptools-%{version}
%if 0%{?fedora} < 37 && 0%{?rhel} < 10 %if 0%{?rhel} && 0%{?rhel} < 10
# The following test deps are optional and either not desired or not available in Fedora: # The following test deps are optional and either not desired or not available in Fedora:
sed -Ei setup.cfg -e '/\bpytest-(checkdocs|black|cov|mypy|enabler)\b/d' \ sed -Ei setup.cfg -e '/\bpytest-(checkdocs|black|cov|mypy|enabler)\b/d' \
-e '/\bflake8\b/d' \ -e '/\bflake8\b/d' \
@ -76,7 +76,7 @@ sed -i pytest.ini -e 's/ --flake8//' \
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files setuptools pkg_resources _distutils_hack %pyproject_save_files setuptools pkg_resources _distutils_hack -l
# https://github.com/pypa/setuptools/issues/2709 # https://github.com/pypa/setuptools/issues/2709
rm -rf %{buildroot}%{python3_sitelib}/pkg_resources/tests/ rm -rf %{buildroot}%{python3_sitelib}/pkg_resources/tests/

View File

@ -52,13 +52,13 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files setuptools_scm %pyproject_save_files -l setuptools_scm
%check %check
# This tox should run all the toxenvs specified via -e in %%pyproject_buildrequires # This tox should run all the toxenvs specified via -e in %%pyproject_buildrequires
# We only run some of the tests (running all of them requires network connection and is slow) # We only run some of the tests (running all of them requires network connection and is slow)
%tox -- -- -k test_version | tee toxlog %tox -- -- -k test_version -Wdefault | tee toxlog
# Internal check for our macros: Assert both toxenvs were executed. # Internal check for our macros: Assert both toxenvs were executed.
grep -E 'py%{python3_version_nodots}-test: (OK|commands succeeded)' toxlog grep -E 'py%{python3_version_nodots}-test: (OK|commands succeeded)' toxlog
@ -73,4 +73,3 @@ test "$(cat %{_pyproject_ghost_distinfo})" == "%ghost %{python3_sitelib}/setupto
%files -n python3-setuptools_scm -f %{pyproject_files} %files -n python3-setuptools_scm -f %{pyproject_files}
%doc README.rst %doc README.rst
%doc CHANGELOG.rst %doc CHANGELOG.rst
%license LICENSE

View File

@ -43,7 +43,7 @@ sed -Ei '/^(coverage)$/d' requirements-dev.txt
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files userpath %pyproject_save_files -l userpath
%check %check

View File

@ -35,6 +35,10 @@ sed -i -e 's/distlib<1,>=0.3.6/distlib<1,>=0.3.2/' \
-e 's/hatchling>=1.12.2/hatchling>=0.25/' \ -e 's/hatchling>=1.12.2/hatchling>=0.25/' \
-e 's/hatch-vcs>=0.3/hatch-vcs>=0.2.1/' \ -e 's/hatch-vcs>=0.3/hatch-vcs>=0.2.1/' \
pyproject.toml pyproject.toml
# Hacky backport of https://src.fedoraproject.org/rpms/python-virtualenv/c/87b1f95664
%if 0%{?fedora} >= 39 || 0%{?rhel} >= 10
sed -i 's/_nonwrappers/_hookimpls/' tests/conftest.py
%endif
%generate_buildrequires %generate_buildrequires
@ -48,7 +52,7 @@ sed -i -e 's/distlib<1,>=0.3.6/distlib<1,>=0.3.2/' \
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files virtualenv %pyproject_save_files -l virtualenv
%{?el9: %{?el9:
# old version of setuptools_scm produces files incompatible with # old version of setuptools_scm produces files incompatible with
# assumptions in virtualenv code, we append the expected attributes: # assumptions in virtualenv code, we append the expected attributes:

View File

@ -32,7 +32,7 @@ Summary: %{summary}
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files zope +auto %pyproject_save_files -l zope +auto
%check %check
# Internal check that the RECORD and REQUESTED files are # Internal check that the RECORD and REQUESTED files are
@ -42,5 +42,4 @@ test ! $(find %{buildroot}%{python3_sitelib}/ | grep -E "\.dist-info/REQUESTED$"
%files -n python3-zope-event -f %{pyproject_files} %files -n python3-zope-event -f %{pyproject_files}
%doc README.rst %doc README.rst
%license LICENSE.txt

View File

@ -110,12 +110,15 @@
- config-settings-test: - config-settings-test:
dir: . dir: .
run: ./mocktest.sh config-settings-test run: ./mocktest.sh config-settings-test
- isort_311: - isort_c9s:
dir: . dir: .
run: ./mocktest.sh python-isort --define 'python3_pkgversion 3.11' run: NAME="CentOS Stream" VERSION_ID=9 ./mocktest.sh python-isort
- mistune_311: - mistune_311:
dir: . dir: .
run: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.11' run: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.11'
- mistune_312:
dir: .
run: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.12'
required_packages: required_packages:
- 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm' - 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm'
- 'https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm' - 'https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm'

View File

@ -36,7 +36,7 @@ Building this tests:
%install %install
%pyproject_install %pyproject_install
%pyproject_save_files tldr +auto %pyproject_save_files -l tldr +auto
%check %check
# Internal check for our macros: tests we don't ship __pycache__ in bindir # Internal check for our macros: tests we don't ship __pycache__ in bindir
@ -62,5 +62,4 @@ grep '^/app' %{pyproject_files}
%endif %endif
%files -f %pyproject_files %files -f %pyproject_files
%license LICENSE
%doc README.md %doc README.md