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 d3dfd5fdb2)
This commit is contained in:
Miro Hrončok 2025-03-11 17:20:37 +01:00
parent b3c0c29a02
commit a82300a517
5 changed files with 33 additions and 28 deletions

View File

@ -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):

View File

@ -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}}" %{?*}
}

View File

@ -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 <mhroncok@redhat.com> - 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 <miro@hroncok.cz> - 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

View File

@ -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',

View File

@ -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