Allow %pyproject_buildrequires -t/-e without tox config on Fedora 40-42

This still does not allow %tox without tox config.

(cherry picked from Fedora commit fb7bcbb068)
This commit is contained in:
Miro Hrončok 2025-03-14 12:35:49 +01:00
parent a82300a517
commit f2e30c24db
3 changed files with 12 additions and 2 deletions

View File

@ -219,7 +219,7 @@ if [ -f %{__python3} ]; then
echo -n > %{_pyproject_buildrequires}
%{_pyproject_build_flags} \\\
TMPDIR="%{_pyproject_builddir}" \\\
RPM_TOXENV="%{toxenv}" HOSTNAME="rpmbuild" %{__python3} -Bs %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?!_python_no_extras_requires:--generate-extras} --python3_pkgversion %{python3_pkgversion} --wheeldir %{_pyproject_wheeldir} --output %{_pyproject_buildrequires} %{?**} >&2
RPM_TOXENV="%{toxenv}" FEDORA=%{?fedora} HOSTNAME="rpmbuild" %{__python3} -Bs %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?!_python_no_extras_requires:--generate-extras} --python3_pkgversion %{python3_pkgversion} --wheeldir %{_pyproject_wheeldir} --output %{_pyproject_buildrequires} %{?**} >&2
cat %{_pyproject_buildrequires}
fi
# Incomplete .dist-info dir might confuse importlib.metadata

View File

@ -193,6 +193,7 @@ 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
- The %%pyproject_buildrequires -t/-e case is temporarily allowed on Fedora 40-42
- Requires tox-current-env >= 0.0.16
* Thu Jan 30 2025 Miro Hrončok <miro@hroncok.cz> - 1.17.0-1

View File

@ -22,6 +22,15 @@ from pyproject_wheel import parse_config_settings_args
# Allow only the forms we know we can handle.
VERSION_RE = re.compile(r'[a-zA-Z0-9.-]+(\.\*)?')
# To avoid breakage on Fedora 40-42,
# we don't assert tox configuration there.
# This can be removed when Fedora 42 goes EOL.
# Note that %tox still uses --assert-config
# because %tox without config is dangerous (false sense of tests).
# Running %pyproject_buildrequires -t/-e without tox config is wrong, but not dangerous.
FEDORA = int(os.getenv('FEDORA') or 0)
TOX_ASSERT_CONFIG_OPTS = ('--assert-config',) if 40 <= FEDORA < 43 else ()
class EndPass(Exception):
"""End current pass of generating requirements"""
@ -426,7 +435,7 @@ def generate_tox_requirements(toxenv, requirements):
'--print-deps-to', deps.name,
'--print-extras-to', extras.name,
'--no-provision', provision.name,
'--assert-config',
*TOX_ASSERT_CONFIG_OPTS,
'-q', '-r', '-e', toxenv],
check=False,
encoding='utf-8',