qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 25/25] python: add tox support


From: John Snow
Subject: [PATCH v6 25/25] python: add tox support
Date: Wed, 12 May 2021 19:12:41 -0400

This is intended to be a manually run, non-CI script.

Use tox to test the linters against all python versions from 3.6 to
3.9. This will only work if you actually have those versions installed
locally, but Fedora makes this easy:

> sudo dnf install python36 python37 python38 python39

Unlike the pipenv tests (make venv-check), this pulls "whichever"
versions of the python packages, so they are unpinned and may break as
time goes on. In the case that breakages are found, setup.cfg should be
amended accordingly to avoid the bad dependant versions, or the code
should be amended to work around the issue.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/README.rst |  2 ++
 python/.gitignore |  1 +
 python/Makefile   |  7 ++++++-
 python/setup.cfg  |  1 +
 python/tox.ini    | 13 +++++++++++++
 5 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 python/tox.ini

diff --git a/python/README.rst b/python/README.rst
index 3e09d20c23c..7360dee32be 100644
--- a/python/README.rst
+++ b/python/README.rst
@@ -49,3 +49,5 @@ Files in this directory
   this package; it is referenced by ``setup.cfg``.
 - ``setup.cfg`` houses setuptools package configuration.
 - ``setup.py`` is the setuptools installer used by pip; See above.
+- ``tox.ini`` houses configuration for tox, which runs tests against
+  several Python versions to test compatibility.
diff --git a/python/.gitignore b/python/.gitignore
index e27c99e009c..d92e3f4bcca 100644
--- a/python/.gitignore
+++ b/python/.gitignore
@@ -17,3 +17,4 @@ qemu.egg-info/
 
 # virtual environments (pipenv et al)
 .venv/
+.tox/
diff --git a/python/Makefile b/python/Makefile
index 184f59e5634..a01db823318 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -16,6 +16,8 @@ help:
        @echo ""
        @echo "make check:      run linters using the current environment."
        @echo ""
+       @echo "make check-tox:  run linters using multiple python versions."
+       @echo ""
        @echo "make clean:      remove build output."
        @echo ""
        @echo "make distclean:  remove venv files, qemu package forwarder, and"
@@ -35,8 +37,11 @@ develop:
 check:
        @avocado --config avocado.cfg run tests/
 
+check-tox:
+       @tox
+
 clean:
        rm -rf build/ dist/
 
 distclean: clean
-       rm -rf qemu.egg-info/ .venv/
+       rm -rf qemu.egg-info/ .venv/ .tox/
diff --git a/python/setup.cfg b/python/setup.cfg
index 364b68434ca..a7c5f636790 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -33,6 +33,7 @@ devel =
 extend-ignore = E722  # Prefer pylint's bare-except checks to flake8's
 exclude = __pycache__,
           .venv,
+          .tox,
 
 [mypy]
 strict = True
diff --git a/python/tox.ini b/python/tox.ini
new file mode 100644
index 00000000000..d8fe503b477
--- /dev/null
+++ b/python/tox.ini
@@ -0,0 +1,13 @@
+# tox (https://tox.readthedocs.io/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py36, py37, py38, py39
+
+[testenv]
+allowlist_externals = make
+deps = .[devel]
+commands =
+    make check
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]