From a82300a517b963500e02de000c845ac23cd086da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 11 Mar 2025 17:20:37 +0100 Subject: [PATCH] Make %pyproject_buildrequires -t/-e and %tox fail when no suitable tox configuration exists Since tox 4, tox does not fail without configuration (tox.ini, or tox section in setup.cfg/pyproject.toml). As a result, packages that use %pyproject_buildrequires with -t or -e without having a tox confuration only generate additional BuildRequires on tox & tox-current-env itself. More dangerously, %tox without tox configuration does nothing (and succeeds). This behavior is dangerous and warrants an announced breakage. Packagers of ~100 affected Fedora packages were informed about the problem earlier in https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/ZSHSHZKVA4XJQBJD7FMMCALKN4UP5SAJ/ There will be a further announcement and warning about this change. EPEL 9 packages are not affected, EPEL 9 has tox 3 which fails without config by default. The change used a newly added option for tox-current-env: --assert-config. This was added in tox-current-env 0.0.16: https://github.com/fedora-python/tox-current-env/pull/89 (cherry picked from Fedora commit d3dfd5fdb251774036ac5c27b6520fe57efc7191) --- README.md | 2 +- macros.pyproject | 2 +- pyproject-rpm-macros.spec | 8 +++-- pyproject_buildrequires.py | 3 +- pyproject_buildrequires_testcases.yaml | 46 +++++++++++++------------- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9837f01..7b5b21c 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ The macro: - Always prepends `$PATH` with `%{buildroot}%{_bindir}` - If not defined, sets `$PYTHONPATH` to `%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}` - If not defined, sets `$TOX_TESTENV_PASSENV` to `*` - - Runs `tox` with `-q` (quiet), `--recreate` and `--current-env` (from [tox-current-env]) flags + - Runs `tox` with `-q` (quiet), `--recreate`, `--current-env` (from [tox-current-env]) and `--assert-config` (from [tox-current-env]) flags - Implicitly uses the tox environment name stored in `%{toxenv}` - as overridden by `%pyproject_buildrequires -e` By using the `-e` flag, you can use a different tox environment(s): diff --git a/macros.pyproject b/macros.pyproject index e5aedd9..4306b9e 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -234,7 +234,7 @@ PATH="%{buildroot}%{_bindir}:$PATH" \\ PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\ %{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}} \\ HOSTNAME="rpmbuild" \\ -%{__python3} -m tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*} +%{__python3} -m tox --current-env --assert-config -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*} } diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index c5942d8..629df6c 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.17.0 +Version: 1.18.0 Release: 1%{?dist} # Macro files @@ -59,7 +59,7 @@ BuildRequires: python3dist(packaging) BuildRequires: python3dist(pip) BuildRequires: python3dist(setuptools) %if %{with tox_tests} -BuildRequires: python3dist(tox-current-env) >= 0.0.6 +BuildRequires: python3dist(tox-current-env) >= 0.0.16 %endif BuildRequires: python3dist(wheel) BuildRequires: (python3dist(tomli) if python3 < 3.11) @@ -191,6 +191,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog +* Tue Mar 11 2025 Miro Hrončok - 1.18.0-1 +- Make %%pyproject_buildrequires -t/-e and %%tox fail when no suitable tox configuration exists +- Requires tox-current-env >= 0.0.16 + * Thu Jan 30 2025 Miro Hrončok - 1.17.0-1 - Add the -M flag to %%pyproject_save_files - The flag can be used to indicate no Python modules should be saved diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index da8a239..2bda7cd 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -416,7 +416,7 @@ def generate_run_requirements(backend, requirements, *, build_wheel, read_pyproj def generate_tox_requirements(toxenv, requirements): toxenv = ','.join(toxenv) - requirements.add('tox-current-env >= 0.0.6', source='tox itself') + requirements.add('tox-current-env >= 0.0.16', source='tox itself') requirements.check(source='tox itself') with tempfile.NamedTemporaryFile('r') as deps, \ tempfile.NamedTemporaryFile('r') as extras, \ @@ -426,6 +426,7 @@ def generate_tox_requirements(toxenv, requirements): '--print-deps-to', deps.name, '--print-extras-to', extras.name, '--no-provision', provision.name, + '--assert-config', '-q', '-r', '-e', toxenv], check=False, encoding='utf-8', diff --git a/pyproject_buildrequires_testcases.yaml b/pyproject_buildrequires_testcases.yaml index a374fa0..bfbb5bd 100644 --- a/pyproject_buildrequires_testcases.yaml +++ b/pyproject_buildrequires_testcases.yaml @@ -456,7 +456,7 @@ tox dependencies: setuptools: 50 wheel: 1 tox: 3.5.3 - tox-current-env: 0.0.6 + tox-current-env: 0.0.16 toxenv: - py3 setup.py: | @@ -479,13 +479,13 @@ tox dependencies: - | # tox 3 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(toxdep1) python3dist(toxdep2) python3dist(inst) - | # tox 4 with setuptools 70+ python3dist(setuptools) >= 40.8 - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) python3dist(toxdep1) python3dist(toxdep2) @@ -493,7 +493,7 @@ tox dependencies: - | # tox 4 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) python3dist(toxdep1) python3dist(toxdep2) @@ -505,7 +505,7 @@ tox extras: setuptools: 50 wheel: 1 tox: 3.5.3 - tox-current-env: 0.0.6 + tox-current-env: 0.0.16 generate_extras: true toxenv: - py3 @@ -536,7 +536,7 @@ tox extras: - | # tox 3 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(toxdep) python3dist(inst) python3dist(dep11) > 11.0 @@ -548,7 +548,7 @@ tox extras: python3dist(extra-dep[extra_dep]) - | # tox 4 with setuptools 70+ python3dist(setuptools) >= 40.8 - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) python3dist(toxdep) python3dist(inst) @@ -562,7 +562,7 @@ tox extras: - | # tox 4 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) python3dist(toxdep) python3dist(inst) @@ -580,7 +580,7 @@ tox provision unsatisfied: setuptools: 50 wheel: 1 tox: 3.5.3 - tox-current-env: 0.0.6 + tox-current-env: 0.0.16 toxenv: - py3 setup.py: | @@ -604,13 +604,13 @@ tox provision unsatisfied: - | # tox 3 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 3.999 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 - | # tox 4 with setuptools 70+ python3dist(setuptools) >= 40.8 - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 3.999 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 @@ -618,7 +618,7 @@ tox provision unsatisfied: - | # tox 4 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 3.999 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 @@ -630,7 +630,7 @@ tox provision satisfied: setuptools: 50 wheel: 1 tox: 3.5.3 - tox-current-env: 0.0.6 + tox-current-env: 0.0.16 toxenv: - py3 setup.py: | @@ -653,7 +653,7 @@ tox provision satisfied: - | # tox 3 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 3.5 python3dist(setuptools) > 40.0 python3dist(toxdep1) @@ -661,7 +661,7 @@ tox provision satisfied: python3dist(inst) - | # tox 4 with setuptools 70+ python3dist(setuptools) >= 40.8 - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(setuptools) > 40.0 python3dist(tox) >= 3.5 python3dist(toxdep1) @@ -670,7 +670,7 @@ tox provision satisfied: - | # tox 4 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(setuptools) > 40.0 python3dist(tox) >= 3.5 python3dist(toxdep1) @@ -683,7 +683,7 @@ tox provision no minversion: setuptools: 50 wheel: 1 tox: 3.5.3 - tox-current-env: 0.0.6 + tox-current-env: 0.0.16 toxenv: - py3 setup.py: | @@ -701,19 +701,19 @@ tox provision no minversion: - | # tox 3 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 - | # tox 4 with setuptools 70+ python3dist(setuptools) >= 40.8 - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 python3dist(tox) - | # tox 4 with setuptools < 70 python3dist(setuptools) >= 40.8 python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(setuptools) > 40.0 python3dist(wheel) > 2.0 python3dist(tox) @@ -1573,7 +1573,7 @@ tox with dependency_groups: setuptools: 50 wheel: 1 tox: 4.22 - tox-current-env: 0.0.14 + tox-current-env: 0.0.16 toxenv: - py3 pyproject.toml: | @@ -1594,7 +1594,7 @@ tox with dependency_groups: expected: - | # setuptools 70+ python3dist(setuptools) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 4.22 python3dist(tox) python3dist(pytest) >= 5 @@ -1602,7 +1602,7 @@ tox with dependency_groups: - | # setuptools < 70 python3dist(setuptools) python3dist(wheel) - python3dist(tox-current-env) >= 0.0.6 + python3dist(tox-current-env) >= 0.0.16 python3dist(tox) >= 4.22 python3dist(tox) python3dist(pytest) >= 5