Skip to contentSkip to conversation

python: Configure tox to skip missing interpreters

PATCH In review Wainer dos Santos Moschetta 3 participants 3 messages Jun 30, 2021 – Jul 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python: Configure tox to skip missing interpreters

Currently tox tests against the installed interpreters, however if any supported interpreter is absent then it will return fail. It seems not reasonable to expect developers to have all supported interpreters installed on their systems. Luckily tox can be configured to skip missing interpreters.

This changed the tox setup so that missing interpreters are skipped by default. On the CI, however, we still want to enforce it tests against all supported. This way on CI the --skip-missing-interpreters=false option is passed to tox.

---
Tested locally with make check-tox and where I only Python 3.6 and 3.9
installed.
Tested on CI: https://gitlab.com/wainersm/qemu/-/jobs/1390010988
Still on CI, but I deliberately removed Python 3.8: https://gitlab.com/wainersm/qemu/-/jobs/1390046531

 .gitlab-ci.d/static_checks.yml | 1 +
 python/Makefile                | 5 ++++-
 python/setup.cfg               | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
.gitlab-ci.d/static_checks.yml +1 -0
index b01f6ec231..96dbd9e310 100644
@@ -43,6 +43,7 @@ check-python-tox:
     - make -C python check-tox
   variables:
     GIT_DEPTH: 1
+    QEMU_TOX_EXTRA_ARGS: --skip-missing-interpreters=false
   needs:
     job: python-container
   allow_failure: true
python/Makefile +4 -1
index ac46ae33e7..fe27a3e12e 100644
@@ -1,4 +1,5 @@
 QEMU_VENV_DIR=.dev-venv
+QEMU_TOX_EXTRA_ARGS ?=
 
 .PHONY: help
 help:
@@ -15,6 +16,8 @@ help:
 	@echo "    These tests use the newest dependencies."
 	@echo "    Requires: Python 3.6 - 3.10, and tox."
 	@echo "    Hint (Fedora): 'sudo dnf install python3-tox python3.10'"
+	@echo "    The variable QEMU_TOX_EXTRA_ARGS can be use to pass extra"
+	@echo "    arguments to tox".
 	@echo ""
 	@echo "make check-dev:"
 	@echo "    Run tests in a venv against your default python3 version."
@@ -87,7 +90,7 @@ check:
 
 .PHONY: check-tox
 check-tox:
-	@tox
+	@tox $(QEMU_TOX_EXTRA_ARGS)
 
 .PHONY: clean
 clean:
python/setup.cfg +1 -0
index 11f71d5312..14bab90288 100644
@@ -121,6 +121,7 @@ multi_line_output=3
 
 [tox:tox]
 envlist = py36, py37, py38, py39, py310
+skip_missing_interpreters = true
 
 [testenv]
 allowlist_externals = make
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Wainer dos Santos Moschetta

Currently tox tests against the installed interpreters, however if any supported interpreter is absent then it will return fail. It seems not reasonable to expect developers to have all supported interpreters installed on their systems. Luckily tox can be configured to skip missing interpreters.

This changed the tox setup so that missing interpreters are skipped by default. On the CI, however, we still want to enforce it tests against all supported. This way on CI the --skip-missing-interpreters=false option is passed to tox.

---
Tested locally with make check-tox and where I only Python 3.6 and 3.9
installed.
Tested on CI: https://gitlab.com/wainersm/qemu/-/jobs/1390010988
Still on CI, but I deliberately removed Python 3.8: https://gitlab.com/wainersm/qemu/-/jobs/1390046531

Quoted 5 lines
 .gitlab-ci.d/static_checks.yml | 1 +
 python/Makefile                | 5 ++++-
 python/setup.cfg               | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

Seems reasonable.

Reviewed-by
#2 lore raw
Quoted 28 lines · Willian Rampazzo
Quoted 12 lines · Wainer dos Santos Moschetta

Currently tox tests against the installed interpreters, however if any supported interpreter is absent then it will return fail. It seems not reasonable to expect developers to have all supported interpreters installed on their systems. Luckily tox can be configured to skip missing interpreters.

This changed the tox setup so that missing interpreters are skipped by default. On the CI, however, we still want to enforce it tests against all supported. This way on CI the --skip-missing-interpreters=false option is passed to tox.

Quoted 6 lines

---
Tested locally with make check-tox and where I only Python 3.6 and 3.9 installed.
Tested on CI: https://gitlab.com/wainersm/qemu/-/jobs/1390010988
Still on CI, but I deliberately removed Python 3.8:

https://gitlab.com/wainersm/qemu/-/jobs/1390046531

Quoted 6 lines
 .gitlab-ci.d/static_checks.yml | 1 +
 python/Makefile                | 5 ++++-
 python/setup.cfg               | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
Quoted 5 lines

Seems reasonable.

Nice, I get to have my cake and eat it too :)