Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/jsnow-gitlab/tags/python-pull-r…
Browse files Browse the repository at this point in the history
…equest' into staging

Pull request

V2:
 - Squashed in fixup for
   'Python: add utility function for retrieving port redirection'
 - Rebased on today's upstream

CI here:
https://gitlab.com/jsnow/qemu/-/pipelines/313202814

# gpg: Signature made Wed 02 Jun 2021 00:29:55 BST
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* remotes/jsnow-gitlab/tags/python-pull-request: (44 commits)
  gitlab: add python linters to CI
  python: add tox support
  python: add .gitignore
  python: add Makefile for some common tasks
  python: add avocado-framework and tests
  python: add devel package requirements to setuptools
  python/qemu: add qemu package itself to pipenv
  python/qemu: add isort to pipenv
  python: move .isort.cfg into setup.cfg
  python: add mypy to pipenv
  python: move mypy.ini into setup.cfg
  python: Add flake8 to pipenv
  python: add excluded dirs to flake8 config
  python: move flake8 config to setup.cfg
  python: add pylint to pipenv
  python: move pylintrc into setup.cfg
  python: add pylint import exceptions
  python: Add pipenv support
  python: add MANIFEST.in
  python: add directory structure README.rst files
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 2, 2021
2 parents dd2db39 + 6b9c277 commit 49ba51a
Show file tree
Hide file tree
Showing 48 changed files with 967 additions and 248 deletions.
5 changes: 5 additions & 0 deletions .gitlab-ci.d/containers.yml
Expand Up @@ -43,3 +43,8 @@ amd64-opensuse-leap-container:
extends: .container_job_template
variables:
NAME: opensuse-leap

python-container:
extends: .container_job_template
variables:
NAME: python
21 changes: 21 additions & 0 deletions .gitlab-ci.d/static_checks.yml
Expand Up @@ -24,3 +24,24 @@ check-dco:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: never
- when: on_success

check-python-pipenv:
stage: test
image: $CI_REGISTRY_IMAGE/qemu/python:latest
script:
- make -C python venv-check
variables:
GIT_DEPTH: 1
needs:
job: python-container

check-python-tox:
stage: test
image: $CI_REGISTRY_IMAGE/qemu/python:latest
script:
- make -C python check-tox
variables:
GIT_DEPTH: 1
needs:
job: python-container
allow_failure: true
26 changes: 26 additions & 0 deletions docs/devel/testing.rst
Expand Up @@ -810,6 +810,32 @@ and hypothetical example follows:
At test "tear down", ``avocado_qemu.Test`` handles all the QEMUMachines
shutdown.

The ``avocado_qemu.LinuxTest`` base test class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``avocado_qemu.LinuxTest`` is further specialization of the
``avocado_qemu.Test`` class, so it contains all the characteristics of
the later plus some extra features.

First of all, this base class is intended for tests that need to
interact with a fully booted and operational Linux guest. At this
time, it uses a Fedora 31 guest image. The most basic example looks
like this:

.. code::
from avocado_qemu import LinuxTest
class SomeTest(LinuxTest):
def test(self):
self.launch_and_wait()
self.ssh_command('some_command_to_be_run_in_the_guest')
Please refer to tests that use ``avocado_qemu.LinuxTest`` under
``tests/acceptance`` for more examples.

QEMUMachine
~~~~~~~~~~~

Expand Down
16 changes: 16 additions & 0 deletions python/.gitignore
@@ -0,0 +1,16 @@
# linter/tooling cache
.mypy_cache/
.cache/

# python packaging
build/
dist/
qemu.egg-info/

# editor config
.idea/
.vscode/

# virtual environments (pipenv et al)
.venv/
.tox/
3 changes: 3 additions & 0 deletions python/MANIFEST.in
@@ -0,0 +1,3 @@
include VERSION
include PACKAGE.rst
exclude README.rst
48 changes: 48 additions & 0 deletions python/Makefile
@@ -0,0 +1,48 @@
.PHONY: help venv venv-check 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 ""
@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 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
.venv: Pipfile.lock
@PIPENV_VENV_IN_PROJECT=1 pipenv sync --dev --keep-outdated
@touch .venv

venv-check: venv
@pipenv run make check

develop:
pip3 install -e .[devel]

check:
@avocado --config avocado.cfg run tests/

check-tox:
@tox

clean:
python3 setup.py clean --all

distclean: clean
rm -rf qemu.egg-info/ .venv/ .tox/ dist/
43 changes: 43 additions & 0 deletions python/PACKAGE.rst
@@ -0,0 +1,43 @@
QEMU Python Tooling
===================

This package provides QEMU tooling used by the QEMU project to build,
configure, and test QEMU. It is not a fully-fledged SDK and it is subject
to change at any time.

Usage
-----

The ``qemu.qmp`` subpackage provides a library for communicating with
QMP servers. The ``qemu.machine`` subpackage offers rudimentary
facilities for launching and managing QEMU processes. Refer to each
package's documentation
(``>>> help(qemu.qmp)``, ``>>> help(qemu.machine)``)
for more information.

Contributing
------------

This package is maintained by John Snow <jsnow@redhat.com> as part of
the QEMU source tree. Contributions are welcome and follow the `QEMU
patch submission process
<https://wiki.qemu.org/Contribute/SubmitAPatch>`_, which involves
sending patches to the QEMU development mailing list.

John maintains a `GitLab staging branch
<https://gitlab.com/jsnow/qemu/-/tree/python>`_, and there is an
official `GitLab mirror <https://gitlab.com/qemu-project/qemu>`_.

Please report bugs on the `QEMU issue tracker
<https://gitlab.com/qemu-project/qemu/-/issues>`_ and tag ``@jsnow`` in
the report.

Optional packages necessary for running code quality analysis for this
package can be installed with the optional dependency group "devel":
``pip install qemu[devel]``.

``make develop`` can be used to install this package in editable mode
(to the current environment) *and* bring in testing dependencies in one
command.

``make check`` can be used to run the available tests.
13 changes: 13 additions & 0 deletions python/Pipfile
@@ -0,0 +1,13 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
qemu = {editable = true, extras = ["devel"], path = "."}

[packages]
qemu = {editable = true,path = "."}

[requires]
python_version = "3.6"

0 comments on commit 49ba51a

Please sign in to comment.