On Thu, Feb 11, 2021 at 01:58:32PM -0500, John Snow wrote: > This series factors the python/qemu directory as an installable > package. It does not yet actually change the mechanics of how any other > python source in the tree actually consumes it (yet), beyond the import > path. (some import statements change in a few places.) > > git: https://gitlab.com/jsnow/qemu/-/commits/python-package-mk3 > CI: https://gitlab.com/jsnow/qemu/-/pipelines/254940717 > (New CI job: https://gitlab.com/jsnow/qemu/-/jobs/1024230604) > > The primary motivation of this series is primarily to formalize our > dependencies on mypy, flake8, isort, and pylint alongside versions that > are known to work. It does this using the setup.cfg and setup.py > files. It also adds explicitly pinned versions (using Pipfile.lock) of > these dependencies that should behave in a repeatable and known way for > developers and CI environments both. Lastly, it enables those CI checks > such that we can enforce Python coding quality checks via the CI tests. > > An auxiliary motivation is that this package is formatted in such a way > that it COULD be uploaded to https://pypi.org/project/qemu and installed > independently of qemu.git with `pip install qemu`, but that button > remains *unpushed* and this series *will not* cause any such > releases. We have time to debate finer points like API guarantees and > versioning even after this series is merged. > > Some other things this enables that might be of interest: > > With the python tooling as a proper package, you can install this > package in editable or production mode to a virtual environment, your > local user environment, or your system packages. The primary benefit of > this is to gain access to QMP tooling regardless of CWD, without needing > to battle sys.path (and confounding other python analysis tools). > > For example: when developing, you may go to qemu/python/ and run `make > venv` followed by `pipenv shell` to activate a virtual environment that > contains the qemu python packages. These packages will always reflect > the current version of the source files in the tree. When you are > finished, you can simply exit the shell (^d) to remove these packages > from your python environment. > > When not developing, you could install a version of this package to your > environment outright to gain access to the QMP and QEMUMachine classes > for lightweight scripting and testing by using pip: "pip install [--user] ." > > TESTING THIS SERIES: > > First of all, nothing should change. Without any intervention, > everything should behave exactly as it was before. The only new > information here comes from how to interact with and run the linters > that will be enforcing code quality standards in this subdirectory. > > To test those, CD to qemu/python first, and then: > > 1. Try "make venv && pipenv shell" to get a venv with the package > installed to it in editable mode. Ctrl+d exits this venv shell. While in > this shell, any python script that uses "from qemu.[qmp|machine] import > ..." should work correctly regardless of where the script is, or what > your CWD is. >
Ack here, works as expected. > You will need Python 3.6 installed on your system to do this step. For > Fedora: "dnf install python3.6" will do the trick. > You may have explained this before, so forgive me asking again. Why is this dependent on a given Python version, and not a *minimum* Python version? Are the checkers themselves susceptible to different behavior depending on the Python version used? If so, any hint on the strategy for developing with say, Python 3.8, and then having issues caught only on Python 3.6? > 2. Try "make check" while still in the shell to run the Python linters > using the venv built in the previous step. This will pull some packages > from PyPI and run pytest, which will in turn execute mypy, flake8, isort > and pylint with the correct arguments. > Works as expected. I'll provide more feedback at the specific patches. > 3. Having exited the shell from above, try "make venv-check". This will > create and update the venv if needed, then run 'make check' within the > context of that shell. It should pass as long as the above did. > If this makes into a documentation (or on a v5), you may just want to tell users to run "deactivate" instead of exiting the shell completely. > 4. Still outside of the venv, you may try running "make check". This > will not install anything, but unless you have the right Python > dependencies installed, these tests may fail for you. You might try > using "pip install --user .[devel]" to install the development packages > needed to run the tests successfully to your local user's python > environment. Once done, you will probably want to "pip uninstall qemu" > to remove that package to avoid it interfering with other things. > This is good info for completeness, but I wonder if "make check" should exist at all. If it's a requirement for "make check-venv", the question becomes if it should be advertised. Hint: I don't think it should, it just adds some a bit of confusion IMO. > 5. "make distclean" will delete the venv and any temporary files that > may have been created by packaging, installing, testing, etc. > Works as expected. Now, unto the individual patches. Cheers, - Cleber.
signature.asc
Description: PGP signature