From 089e2518ea0a612e7f1f6386144a5cb8a9ed76bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 25 Sep 2023 14:32:43 +0200 Subject: [PATCH] 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. --- pyproject-rpm-macros.spec | 4 ++- pyproject_buildrequires.py | 2 +- pyproject_buildrequires_testcases.yaml | 37 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 95afac5..6406766 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -171,8 +171,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog -* Wed Sep 13 2023 Karolina Surma - 1.10.0-1 +* Wed Sep 13 2023 Python Maint - 1.10.0-1 - Add %%_pyproject_check_import_allow_no_modules for automated environments +- Fix handling of tox 4 provision without and explicit tox minversion +- Fixes: rhbz#2240590 * Fri Jul 21 2023 Fedora Release Engineering - 1.9.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index 844fd38..7b0fc87 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -386,7 +386,7 @@ def generate_tox_requirements(toxenv, requirements): provision_content = provision.read() if provision_content and r.returncode != 0: 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"]}', source='tox provision (minversion)') if 'requires' in provision_requires: diff --git a/pyproject_buildrequires_testcases.yaml b/pyproject_buildrequires_testcases.yaml index aba6002..2e6e91e 100644 --- a/pyproject_buildrequires_testcases.yaml +++ b/pyproject_buildrequires_testcases.yaml @@ -589,6 +589,43 @@ tox provision satisfied: python3dist(inst) 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: installed: setuptools: 50