Message ID | 20210512231241.2816122-26-jsnow@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | python: create installable package | expand |
On Wed, May 12, 2021 at 07:12:41PM -0400, John Snow wrote: > 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 > This works as intended for me. A couple of notes / suggestions for future improvements: * `dnf install tox` pulled all the Python versions available (I assume as suggestions) automatically * tox.ini can be folded into setup.cfg * a custom container image with all those Python versions may be handy for running both the pipenv based job (along with the suggestions on the previous patch) and an on-demand, "allow_failure" tox based CI job. Other than those suggestions, this LGTM! Reviewed-by: Cleber Rosa <crosa@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com>
On 5/25/21 4:15 PM, Cleber Rosa wrote: > On Wed, May 12, 2021 at 07:12:41PM -0400, John Snow wrote: >> 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 >> > > This works as intended for me. A couple of notes / suggestions > for future improvements: > > * `dnf install tox` pulled all the Python versions available (I > assume as suggestions) automatically > > * tox.ini can be folded into setup.cfg > Done! > * a custom container image with all those Python versions may be > handy for running both the pipenv based job (along with the > suggestions on the previous patch) and an on-demand, > "allow_failure" tox based CI job. > Yeah, I was thinking this would be good, too! I think at this point, it's going to be a follow-up, though. Because ideally, yes, this SHOULD pass -- it's just that it needs a fairly particular environment to run in, which is annoying, so it's here as an optional-ish thing for now. Maybe I'll make a new fedora:latest container that's meant solely for testing python stuff, because it's just such a convenient distro for it. Later, though. > Other than those suggestions, this LGTM! > > Reviewed-by: Cleber Rosa <crosa@redhat.com> > Tested-by: Cleber Rosa <crosa@redhat.com> >
On Tue, May 25, 2021 at 04:25:37PM -0400, John Snow wrote: > On 5/25/21 4:15 PM, Cleber Rosa wrote: > > On Wed, May 12, 2021 at 07:12:41PM -0400, John Snow wrote: > > > 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 > > > > > > > This works as intended for me. A couple of notes / suggestions > > for future improvements: > > > > * `dnf install tox` pulled all the Python versions available (I > > assume as suggestions) automatically > > > > * tox.ini can be folded into setup.cfg > > > > Done! > Nice! > > * a custom container image with all those Python versions may be > > handy for running both the pipenv based job (along with the > > suggestions on the previous patch) and an on-demand, > > "allow_failure" tox based CI job. > > > > Yeah, I was thinking this would be good, too! > > I think at this point, it's going to be a follow-up, though. Because > ideally, yes, this SHOULD pass -- it's just that it needs a fairly > particular environment to run in, which is annoying, so it's here as an > optional-ish thing for now. > > Maybe I'll make a new fedora:latest container that's meant solely for > testing python stuff, because it's just such a convenient distro for it. > > Later, though. > Sure. > > Other than those suggestions, this LGTM! > > > > Reviewed-by: Cleber Rosa <crosa@redhat.com> > > Tested-by: Cleber Rosa <crosa@redhat.com> > > > >
On 5/25/21 4:46 PM, Cleber Rosa wrote: > On Tue, May 25, 2021 at 04:25:37PM -0400, John Snow wrote: >> On 5/25/21 4:15 PM, Cleber Rosa wrote: >>> On Wed, May 12, 2021 at 07:12:41PM -0400, John Snow wrote: >>>> 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 >>>> >>> >>> This works as intended for me. A couple of notes / suggestions >>> for future improvements: >>> >>> * `dnf install tox` pulled all the Python versions available (I >>> assume as suggestions) automatically >>> >>> * tox.ini can be folded into setup.cfg >>> >> >> Done! >> > > Nice! > >>> * a custom container image with all those Python versions may be >>> handy for running both the pipenv based job (along with the >>> suggestions on the previous patch) and an on-demand, >>> "allow_failure" tox based CI job. >>> >> >> Yeah, I was thinking this would be good, too! >> >> I think at this point, it's going to be a follow-up, though. Because >> ideally, yes, this SHOULD pass -- it's just that it needs a fairly >> particular environment to run in, which is annoying, so it's here as an >> optional-ish thing for now. >> >> Maybe I'll make a new fedora:latest container that's meant solely for >> testing python stuff, because it's just such a convenient distro for it. >> >> Later, though. >> > > Sure. > >>> Other than those suggestions, this LGTM! >>> >>> Reviewed-by: Cleber Rosa <crosa@redhat.com> >>> Tested-by: Cleber Rosa <crosa@redhat.com> >>> >> >>
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