From 6f84d726f3fe5e0f8c3b8dd36100ed9ab446ce1e Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:15 -0400 Subject: python: rename 'venv-check' target to 'check-pipenv' Well, Cleber was right, this is a better name. In preparation for adding a different kind of virtual environment check (One that simply uses whichever version of Python you happen to have), rename this test 'check-pipenv' so that it matches the CI job 'check-python-pipenv'. Remove the "If you don't know which test to run" hint, because it's not actually likely you have Python 3.6 installed to be able to run the test. It's still the test I'd most prefer you to run, but it's not the test you are most likely to be able to run. Rename the 'venv' target to 'pipenv' as well, and move the more pertinent help text under the 'check-pipenv' target. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-8-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index b5621b0d54..07ad73ccd0 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,15 +1,13 @@ -.PHONY: help venv venv-check check clean distclean develop +.PHONY: help pipenv check-pipenv check clean distclean develop help: @echo "python packaging help:" @echo "" - @echo "make venv: Create pipenv's virtual environment." - @echo " NOTE: Requires Python 3.6 and pipenv." - @echo " Will download packages from PyPI." - @echo " Hint: (On Fedora): 'sudo dnf install python36 pipenv'" - @echo "" - @echo "make venv-check: run linters using pipenv's virtual environment." - @echo " Hint: If you don't know which test to run, run this one!" + @echo "make check-pipenv:" + @echo " Run tests in pipenv's virtual environment." + @echo " These tests use the oldest dependencies." + @echo " Requires: Python 3.6 and pipenv." + @echo " Hint (Fedora): 'sudo dnf install python3.6 pipenv'" @echo "" @echo "make develop: Install deps for 'make check', and" @echo " the qemu libs in editable/development mode." @@ -18,18 +16,21 @@ help: @echo "" @echo "make check-tox: run linters using multiple python versions." @echo "" + @echo "make pipenv" + @echo " Creates pipenv's virtual environment (.venv)" + @echo "" @echo "make clean: remove package build output." @echo "" @echo "make distclean: remove venv files, qemu package forwarder," @echo " built distribution files, and everything" @echo " from 'make clean'." -venv: .venv +pipenv: .venv .venv: Pipfile.lock @PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --keep-outdated @touch .venv -venv-check: venv +check-pipenv: pipenv @pipenv run make check develop: -- cgit 1.4.1 From 8c95d0fc7f905fb952818e934169a8abcc9a4c56 Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:16 -0400 Subject: python: update help text for check-tox Move it up near the check-pipenv help text, and update it to suggest parity. (At the time I first added it, I wasn't sure if I would be keeping it, but I've come to appreciate it as it has actually helped uncover bugs I would not have noticed without it. It should stay.) Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-9-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index 07ad73ccd0..d2cfa6ad8f 100644 --- a/python/Makefile +++ b/python/Makefile @@ -9,13 +9,17 @@ help: @echo " Requires: Python 3.6 and pipenv." @echo " Hint (Fedora): 'sudo dnf install python3.6 pipenv'" @echo "" + @echo "make check-tox:" + @echo " Run tests against multiple python versions." + @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 "" @echo "make develop: Install deps for 'make check', and" @echo " the qemu libs in editable/development mode." @echo "" @echo "make check: run linters using the current environment." @echo "" - @echo "make check-tox: run linters using multiple python versions." - @echo "" @echo "make pipenv" @echo " Creates pipenv's virtual environment (.venv)" @echo "" -- cgit 1.4.1 From 205d7219f3ba9971149b6fa45a155866d9e889db Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:17 -0400 Subject: python: Fix .PHONY Make specifiers I missed the 'check-tox' target. Add that, but split the large .PHONY specifier at the top into its component pieces and move them near the targets they describe so that they're much harder to forget to update. Signed-off-by: John Snow Reviewed-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo Message-id: 20210629214323.1329806-10-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index d2cfa6ad8f..d34c4e35d9 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,5 +1,4 @@ -.PHONY: help pipenv check-pipenv check clean distclean develop - +.PHONY: help help: @echo "python packaging help:" @echo "" @@ -29,25 +28,32 @@ help: @echo " built distribution files, and everything" @echo " from 'make clean'." +.PHONY: pipenv pipenv: .venv .venv: Pipfile.lock @PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --keep-outdated @touch .venv +.PHONY: check-pipenv check-pipenv: pipenv @pipenv run make check +.PHONY: develop develop: pip3 install -e .[devel] +.PHONY: check check: @avocado --config avocado.cfg run tests/ +.PHONY: check-tox check-tox: @tox +.PHONY: clean clean: python3 setup.py clean --all +.PHONY: distclean distclean: clean rm -rf qemu.egg-info/ .venv/ .tox/ dist/ -- cgit 1.4.1 From 2c24d52d06af855a9b2a69c38cd4b747c848b1e1 Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:19 -0400 Subject: python: add 'make check-dev' invocation This is a *third* way to run the Python tests. Unlike the first two (check-pipenv, check-tox), this version does not require any specific interpreter version -- making it a lot easier to tell people to run it as a quick smoketest prior to submission to GitLab CI. Summary: Checked via GitLab CI: - check-pipenv: tests our oldest python & dependencies - check-tox: tests newest dependencies on all non-EOL python versions Executed only incidentally: - check-dev: tests newest dependencies on whichever python version ('make check' does not set up any environment at all, it just runs the tests in your current environment. All four invocations perform the exact same tests, just in different execution environments.) Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Tested-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-12-jsnow@redhat.com [Maintainer edit: added .dev-venv/ to .gitignore. --js] Acked-by: Wainer dos Santos Moschetta Acked-by: Willian Rampazzo Signed-off-by: John Snow --- python/.gitignore | 1 + python/Makefile | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'python/Makefile') diff --git a/python/.gitignore b/python/.gitignore index 272ed223a8..c8b0e67fe6 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -14,3 +14,4 @@ qemu.egg-info/ # virtual environments (pipenv et al) .venv/ .tox/ +.dev-venv/ diff --git a/python/Makefile b/python/Makefile index d34c4e35d9..8f8e1999c0 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,3 +1,5 @@ +QEMU_VENV_DIR=.dev-venv + .PHONY: help help: @echo "python packaging help:" @@ -14,6 +16,11 @@ help: @echo " Requires: Python 3.6 - 3.10, and tox." @echo " Hint (Fedora): 'sudo dnf install python3-tox python3.10'" @echo "" + @echo "make check-dev:" + @echo " Run tests in a venv against your default python3 version." + @echo " These tests use the newest dependencies." + @echo " Requires: Python 3.x" + @echo "" @echo "make develop: Install deps for 'make check', and" @echo " the qemu libs in editable/development mode." @echo "" @@ -22,6 +29,9 @@ help: @echo "make pipenv" @echo " Creates pipenv's virtual environment (.venv)" @echo "" + @echo "make dev-venv" + @echo " Creates a simple venv for check-dev. ($(QEMU_VENV_DIR))" + @echo "" @echo "make clean: remove package build output." @echo "" @echo "make distclean: remove venv files, qemu package forwarder," @@ -38,9 +48,30 @@ pipenv: .venv check-pipenv: pipenv @pipenv run make check +.PHONY: dev-venv +dev-venv: $(QEMU_VENV_DIR) $(QEMU_VENV_DIR)/bin/activate +$(QEMU_VENV_DIR) $(QEMU_VENV_DIR)/bin/activate: setup.cfg + @echo "VENV $(QEMU_VENV_DIR)" + @python3 -m venv $(QEMU_VENV_DIR) + @( \ + echo "ACTIVATE $(QEMU_VENV_DIR)"; \ + . $(QEMU_VENV_DIR)/bin/activate; \ + echo "INSTALL qemu[devel] $(QEMU_VENV_DIR)"; \ + make develop 1>/dev/null; \ + ) + @touch $(QEMU_VENV_DIR) + +.PHONY: check-dev +check-dev: dev-venv + @( \ + echo "ACTIVATE $(QEMU_VENV_DIR)"; \ + . $(QEMU_VENV_DIR)/bin/activate; \ + make check; \ + ) + .PHONY: develop develop: - pip3 install -e .[devel] + pip3 install --disable-pip-version-check -e .[devel] .PHONY: check check: @@ -56,4 +87,4 @@ clean: .PHONY: distclean distclean: clean - rm -rf qemu.egg-info/ .venv/ .tox/ dist/ + rm -rf qemu.egg-info/ .venv/ .tox/ $(QEMU_VENV_DIR) dist/ -- cgit 1.4.1 From 28cd32fb7bcd4ff3f987e9cd59186b18e810d73d Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:20 -0400 Subject: python: Update help text on 'make check', 'make develop' Update for visual parity with the other targets. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-13-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index 8f8e1999c0..a14705d12e 100644 --- a/python/Makefile +++ b/python/Makefile @@ -21,10 +21,14 @@ help: @echo " These tests use the newest dependencies." @echo " Requires: Python 3.x" @echo "" - @echo "make develop: Install deps for 'make check', and" - @echo " the qemu libs in editable/development mode." + @echo "make check:" + @echo " Run tests in your *current environment*." + @echo " Performs no environment setup of any kind." @echo "" - @echo "make check: run linters using the current environment." + @echo "make develop:" + @echo " Install deps needed for for 'make check'," + @echo " and install the qemu package in editable mode." + @echo " (Can be used in or outside of a venv.)" @echo "" @echo "make pipenv" @echo " Creates pipenv's virtual environment (.venv)" -- cgit 1.4.1 From 50d0fba8272a5ccc2821e8ca66a5932281b1ca2d Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:21 -0400 Subject: python: Update help text on 'make clean', 'make distclean' Update for visual parity with all the remaining targets. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-14-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index a14705d12e..0432ee0022 100644 --- a/python/Makefile +++ b/python/Makefile @@ -36,11 +36,14 @@ help: @echo "make dev-venv" @echo " Creates a simple venv for check-dev. ($(QEMU_VENV_DIR))" @echo "" - @echo "make clean: remove package build output." + @echo "make clean:" + @echo " Remove package build output." @echo "" - @echo "make distclean: remove venv files, qemu package forwarder," - @echo " built distribution files, and everything" - @echo " from 'make clean'." + @echo "make distclean:" + @echo " remove pipenv/venv files, qemu package forwarder," + @echo " built distribution files, and everything from 'make clean'." + @echo "" + @echo -e "Have a nice day ^_^\n" .PHONY: pipenv pipenv: .venv -- cgit 1.4.1 From 19cf0031e438374045aab8e5db0a03fb3b3070e4 Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:22 -0400 Subject: python: remove auto-generated pyproject.toml file For reasons that at-present escape me, pipenv insists on creating a stub pyproject.toml file. This file is a nuisance, because its mere presence changes the behavior of various tools. For instance, this stub file will cause "pip install --user -e ." to fail in spectacular fashion with misleading errors. "pip install -e ." works okay, but for some reason pip does not support editable installs to the user directory when using PEP517. References: https://github.com/pypa/pip/pull/9990 https://github.com/pypa/pip/issues/7953 As outlined in ea1213b7ccc, it is still too early for us to consider moving to a PEP-517 exclusive package. We must support older distributions, so squash the annoyance for now. (Python 3.6 shipped Dec 2016, PEP517 support showed up in pip sometime in 2019 or so.) Add 'pyproject.toml' to the 'make clean' target, and also delete it after every pipenv invocation issued by the Makefile. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-15-jsnow@redhat.com Signed-off-by: John Snow --- python/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index 0432ee0022..ac46ae33e7 100644 --- a/python/Makefile +++ b/python/Makefile @@ -49,6 +49,7 @@ help: pipenv: .venv .venv: Pipfile.lock @PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --keep-outdated + rm -f pyproject.toml @touch .venv .PHONY: check-pipenv @@ -91,6 +92,7 @@ check-tox: .PHONY: clean clean: python3 setup.py clean --all + rm -f pyproject.toml .PHONY: distclean distclean: clean -- cgit 1.4.1