python: create installable package
v2 cover python: create installable package
Based-on: https://gitlab.com/jsnow/qemu/-/tree/python
This series factors the python/qemu directory as an installable module. 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.
The point of this series is primarily to formalize our dependencies on mypy, flake8, isort, and pylint alongside versions that are known to work. It also adds explicitly pinned versions of these dependencies that should behave in a repeatable and known way for developers and CI environments both.
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.
For example: when developing, you may go to qemu/python/ and invoke pipenv shell to activate a virtual environment that contains the qemu packages. This package will always reflect the current version of the source files in the tree. When you are finished, you can simply exit the shell 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] ."
Finally, 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.
TESTING THIS SERIES:
CD to qemu/python first, and then:
1. Try "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.core import ..." should work correctly regardless of your CWD.
2. Try "pipenv sync --dev" to create/update the venv with the development packages without actually entering the venv. This should install isort, mypy, flake8 and pylint to the venv.
3. After the above sync, try "pipenv shell" again, and from the python project root, try any of the following:
- pylint qemu
- flake8 qemu
- isort -c qemu
- mypy qemu
4. Leave any venv you are in, and from the project root, try the following commands:
- pipenv run pylint qemu
- pipenv run flake8 qemu
- pipenv run isort -c qemu
- pipenv run mypy qemu
John Snow (15):
python: create qemu.core package
python: add qemu package installer
python: add VERSION file
python: add directory structure README.rst files
python: Add pipenv support
python: add pylint exceptions to __init__.py
python: move pylintrc into setup.cfg
python: add pylint to pipenv
python: move flake8 config to setup.cfg
python: Add flake8 to pipenv
python: move mypy.ini into setup.cfg
python: add mypy to pipenv
python: move .isort.cfg into setup.cfg python/qemu: add isort to pipenv python/qemu: add qemu package itself to pipenv
python/PACKAGE.rst | 23 +++
python/README.rst | 27 +++
python/qemu/README.rst | 8 +
python/qemu/core/README.rst | 9 +
python/Pipfile | 16 ++
python/Pipfile.lock | 207 ++++++++++++++++++++++
python/VERSION | 1 +
python/mypy.ini | 4 -
python/qemu/.flake8 | 2 -
python/qemu/.isort.cfg | 7 -
python/qemu/__init__.py | 11 --
python/qemu/core/__init__.py | 47 +++++
python/qemu/{ => core}/accel.py | 0
python/qemu/{ => core}/console_socket.py | 0
python/qemu/{ => core}/machine.py | 0
python/qemu/{ => core}/qmp.py | 0
python/qemu/{ => core}/qtest.py | 0
python/{qemu/pylintrc => setup.cfg} | 66 +++----
python/setup.py | 23 +++
scripts/device-crash-test | 2 +-
scripts/qmp/qemu-ga-client | 2 +-
scripts/qmp/qmp | 2 +-
scripts/qmp/qmp-shell | 2 +-
scripts/qmp/qom-fuse | 2 +-
scripts/qmp/qom-get | 2 +-
scripts/qmp/qom-list | 2 +-
scripts/qmp/qom-set | 2 +-
scripts/qmp/qom-tree | 2 +-
scripts/render_block_graph.py | 6 +-
scripts/simplebench/bench_block_job.py | 4 +-
tests/acceptance/avocado_qemu/__init__.py | 2 +-
tests/acceptance/boot_linux.py | 3 +-
tests/acceptance/virtio_check_params.py | 2 +-
tests/acceptance/virtio_version.py | 2 +-
tests/migration/guestperf/engine.py | 2 +-
tests/qemu-iotests/235 | 2 +-
tests/qemu-iotests/297 | 2 +-
tests/qemu-iotests/300 | 4 +-
tests/qemu-iotests/iotests.py | 4 +-
tests/vm/basevm.py | 6 +-
40 files changed, 424 insertions(+), 84 deletions(-)
create mode 100644 python/PACKAGE.rst
create mode 100644 python/README.rst
create mode 100644 python/qemu/README.rst
create mode 100644 python/qemu/core/README.rst
create mode 100644 python/Pipfile
create mode 100644 python/Pipfile.lock
create mode 100644 python/VERSION
delete mode 100644 python/mypy.ini
delete mode 100644 python/qemu/.flake8
delete mode 100644 python/qemu/.isort.cfg
delete mode 100644 python/qemu/__init__.py
create mode 100644 python/qemu/core/__init__.py
rename python/qemu/{ => core}/accel.py (100%)
rename python/qemu/{ => core}/console_socket.py (100%)
rename python/qemu/{ => core}/machine.py (100%)
rename python/qemu/{ => core}/qmp.py (100%)
rename python/qemu/{ => core}/qtest.py (100%)
rename python/{qemu/pylintrc => setup.cfg} (51%)
mode change 100644 => 100755
create mode 100755 python/setup.pySignature · 1 line
2.26.2
PATCH v2 1/15 python: create qemu.core package
move python/qemu/*.py to python/qemu/core/*.py and update import directives across the tree.
This is done to create a PEP420 namespace package, in which we may create subpackages. To do this, the namespace directory ("qemu") should not have any modules in it. Those files will go in a new 'core' subpackage instead.
Bolster the core/__init__.py module, making the top-level classes and functions from this package available directly inside the qemu.core namespace.
This facilitates the convenient shorthand:
Quoted 1 line
from qemu.core import QEMUQtestMachine, QEMUMonitorProtocol
---
python/{qemu => }/.isort.cfg | 0
python/qemu/__init__.py | 11 ------
python/qemu/{ => core}/.flake8 | 0
python/qemu/core/__init__.py | 44 +++++++++++++++++++++++
python/qemu/{ => core}/accel.py | 0
python/qemu/{ => core}/console_socket.py | 0
python/qemu/{ => core}/machine.py | 0
python/qemu/{ => core}/pylintrc | 0
python/qemu/{ => core}/qmp.py | 0
python/qemu/{ => core}/qtest.py | 0
scripts/device-crash-test | 2 +-
scripts/qmp/qemu-ga-client | 2 +-
scripts/qmp/qmp | 2 +-
scripts/qmp/qmp-shell | 2 +-
scripts/qmp/qom-fuse | 2 +-
scripts/qmp/qom-get | 2 +-
scripts/qmp/qom-list | 2 +-
scripts/qmp/qom-set | 2 +-
scripts/qmp/qom-tree | 2 +-
scripts/render_block_graph.py | 6 ++--
scripts/simplebench/bench_block_job.py | 4 +--
tests/acceptance/avocado_qemu/__init__.py | 2 +-
tests/acceptance/boot_linux.py | 3 +-
tests/acceptance/virtio_check_params.py | 2 +-
tests/acceptance/virtio_version.py | 2 +-
tests/migration/guestperf/engine.py | 2 +-
tests/qemu-iotests/235 | 2 +-
tests/qemu-iotests/297 | 2 +-
tests/qemu-iotests/300 | 4 +--
tests/qemu-iotests/iotests.py | 4 +--
tests/vm/basevm.py | 6 ++--
31 files changed, 71 insertions(+), 41 deletions(-)
rename python/{qemu => }/.isort.cfg (100%)
delete mode 100644 python/qemu/__init__.py
rename python/qemu/{ => core}/.flake8 (100%)
create mode 100644 python/qemu/core/__init__.py
rename python/qemu/{ => core}/accel.py (100%)
rename python/qemu/{ => core}/console_socket.py (100%)
rename python/qemu/{ => core}/machine.py (100%)
rename python/qemu/{ => core}/pylintrc (100%)
rename python/qemu/{ => core}/qmp.py (100%)
rename python/qemu/{ => core}/qtest.py (100%)python/.isort.cfg renamed from python/qemu/.isort.cfg +0 -0
python/qemu/__init__.py deleted +0 -11
@@ -1,11 +0,0 @@ -# QEMU library -# -# Copyright (C) 2015-2016 Red Hat Inc. -# Copyright (C) 2012 IBM Corp. -# -# Authors: -# Fam Zheng <[email protected]> -# -# This work is licensed under the terms of the GNU GPL, version 2. See -# the COPYING file in the top-level directory. -#
python/qemu/core/.flake8 renamed from python/qemu/.flake8 +0 -0
python/qemu/core/__init__.py new file +44 -0
44 lines not on this page · raw message
python/qemu/core/accel.py renamed from python/qemu/accel.py +0 -0
python/qemu/core/console_socket.py renamed from python/qemu/console_socket.py +0 -0
python/qemu/core/machine.py renamed from python/qemu/machine.py +0 -0
python/qemu/core/pylintrc renamed from python/qemu/pylintrc +0 -0
python/qemu/core/qmp.py renamed from python/qemu/qmp.py +0 -0
python/qemu/core/qtest.py renamed from python/qemu/qtest.py +0 -0
scripts/device-crash-test +1 -1
@@ -35,7 +35,7 @@ import argparse from itertools import chain sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine logger = logging.getLogger('device-crash-test') dbg = logger.debug
scripts/qmp/qemu-ga-client +1 -1
@@ -42,7 +42,7 @@ import base64 import random sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import qmp +from qemu.core import qmp class QemuGuestAgent(qmp.QEMUMonitorProtocol):
scripts/qmp/qmp +1 -1
@@ -13,7 +13,7 @@ import sys, os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol def print_response(rsp, prefix=[]): if type(rsp) == list:
scripts/qmp/qmp-shell +1 -1
@@ -75,7 +75,7 @@ import atexit import re sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import qmp +from qemu.core import qmp class QMPCompleter(list): def complete(self, text, state):
scripts/qmp/qom-fuse +1 -1
@@ -19,7 +19,7 @@ import os, posix, sys from errno import * sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol fuse.fuse_python_api = (0, 2)
scripts/qmp/qom-get +1 -1
@@ -15,7 +15,7 @@ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol cmd, args = sys.argv[0], sys.argv[1:] socket_path = None
scripts/qmp/qom-list +1 -1
@@ -15,7 +15,7 @@ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol cmd, args = sys.argv[0], sys.argv[1:] socket_path = None
scripts/qmp/qom-set +1 -1
@@ -15,7 +15,7 @@ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol cmd, args = sys.argv[0], sys.argv[1:] socket_path = None
scripts/qmp/qom-tree +1 -1
@@ -17,7 +17,7 @@ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.core import QEMUMonitorProtocol cmd, args = sys.argv[0], sys.argv[1:] socket_path = None
scripts/render_block_graph.py +2 -4
@@ -25,10 +25,8 @@ from graphviz import Digraph sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.qmp import ( - QEMUMonitorProtocol, - QMPResponseError, -) +from qemu.core import QEMUMonitorProtocol +from qemu.core.qmp import QMPResponseError def perm(arr):
scripts/simplebench/bench_block_job.py +2 -2
@@ -25,8 +25,8 @@ import json sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.machine import QEMUMachine -from qemu.qmp import QMPConnectError +from qemu.core import QEMUMachine +from qemu.core.qmp import QMPConnectError def bench_block_job(cmd, cmd_args, qemu_args):
tests/acceptance/avocado_qemu/__init__.py +1 -1
@@ -32,7 +32,7 @@ sys.path.append(os.path.join(SOURCE_DIR, 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine def is_readable_executable_file(path): return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
tests/acceptance/boot_linux.py +1 -2
@@ -12,8 +12,7 @@ from avocado_qemu import Test, BUILD_DIR -from qemu.accel import kvm_available -from qemu.accel import tcg_available +from qemu.core import kvm_available, tcg_available from avocado.utils import cloudinit from avocado.utils import network
tests/acceptance/virtio_check_params.py +1 -1
@@ -23,7 +23,7 @@ import logging sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine from avocado_qemu import Test from avocado import skip
tests/acceptance/virtio_version.py +1 -1
@@ -12,7 +12,7 @@ import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine from avocado_qemu import Test # Virtio Device IDs:
tests/migration/guestperf/engine.py +1 -1
@@ -29,7 +29,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine class Engine(object):
tests/qemu-iotests/235 +1 -1
@@ -25,7 +25,7 @@ from iotests import qemu_img_create, qemu_io, file_path, log sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.machine import QEMUMachine +from qemu.core import QEMUMachine iotests.script_initialize(supported_fmts=['qcow2'])
tests/qemu-iotests/297 +1 -1
@@ -36,7 +36,7 @@ MYPYPATH=../../python/ mypy --warn-unused-configs --disallow-subclassing-any \ --disallow-any-generics --disallow-incomplete-defs \ --disallow-untyped-decorators --no-implicit-optional \ --warn-redundant-casts --warn-unused-ignores \ - --no-implicit-reexport iotests.py + --no-implicit-reexport --namespace-packages iotests.py # success, all done echo "*** done"
tests/qemu-iotests/300 +2 -2
@@ -23,7 +23,7 @@ import random import re from typing import Dict, List, Optional, Union import iotests -import qemu +from qemu.core import machine BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
@@ -454,7 +454,7 @@ class TestBlockBitmapMappingErrors(TestDirtyBitmapMigration): # the failed migration try: self.vm_b.shutdown() - except qemu.machine.AbnormalShutdown: + except machine.AbnormalShutdown: pass def test_aliased_bitmap_name_too_long(self) -> None:
tests/qemu-iotests/iotests.py +2 -2
@@ -37,8 +37,8 @@ # pylint: disable=import-error, wrong-import-position sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import qtest -from qemu.qmp import QMPMessage +from qemu.core import qtest +from qemu.core.qmp import QMPMessage # Use this logger for logging messages directly from the iotests module logger = logging.getLogger('qemu.iotests')
tests/vm/basevm.py +3 -3
@@ -18,9 +18,6 @@ import logging import time import datetime -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.accel import kvm_available -from qemu.machine import QEMUMachine import subprocess import hashlib import argparse
@@ -31,6 +28,9 @@ import traceback import shlex +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) +from qemu.core import kvm_available, QEMUMachine + SSH_KEY_FILE = os.path.join(os.path.dirname(__file__), "..", "keys", "id_rsa") SSH_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__),
Signature · 1 line
2.26.2
Re: [PATCH v2 01/15] python: create qemu.core package
Quoted 42 lines · John Snow
move python/qemu/*.py to python/qemu/core/*.py and update import directives across the tree.
This is done to create a PEP420 namespace package, in which we may create subpackages. To do this, the namespace directory ("qemu") should not have any modules in it. Those files will go in a new 'core' subpackage instead.
Bolster the
core/__init__.pymodule, making the top-level classes and functions from this package available directly inside theqemu.corenamespace.This facilitates the convenient shorthand:
Quoted 1 line
from qemu.core import QEMUQtestMachine, QEMUMonitorProtocol
Signed-off-by John Snow <[email protected]>--- python/{qemu => }/.isort.cfg | 0 python/qemu/__init__.py | 11 ------ python/qemu/{ => core}/.flake8 | 0 python/qemu/core/__init__.py | 44 +++++++++++++++++++++++ python/qemu/{ => core}/accel.py | 0 python/qemu/{ => core}/console_socket.py | 0 python/qemu/{ => core}/machine.py | 0 python/qemu/{ => core}/pylintrc | 0 python/qemu/{ => core}/qmp.py | 0 python/qemu/{ => core}/qtest.py | 0 scripts/device-crash-test | 2 +- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qmp | 2 +- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qom-fuse | 2 +- scripts/qmp/qom-get | 2 +- scripts/qmp/qom-list | 2 +- scripts/qmp/qom-set | 2 +- scripts/qmp/qom-tree | 2 +- scripts/render_block_graph.py | 6 ++-- scripts/simplebench/bench_block_job.py | 4 +-- tests/acceptance/avocado_qemu/__init__.py | 2 +- tests/acceptance/boot_linux.py | 3 +- tests/acceptance/virtio_check_params.py | 2 +-
Quoted 8 lines
tests/acceptance/virtio_version.py | 2 +- tests/migration/guestperf/engine.py | 2 +- tests/qemu-iotests/235 | 2 +- tests/qemu-iotests/297 | 2 +- tests/qemu-iotests/300 | 4 +-- tests/qemu-iotests/iotests.py | 4 +-- tests/vm/basevm.py | 6 ++-- 31 files changed, 71 insertions(+), 41 deletions(-)
PATCH v2 2/15 python: add qemu package installer
In reply to John SnowAdd setup.cfg and setup.py, necessary for installing a package via pip. Add a rst document explaining the basics of what this package is for and who to contact for more information. This document will be used as the landing page for the package on PyPI.
I am not yet using a pyproject.toml style package manifest, because using pyproject.toml (and PEP-517) style packages means that pip is not able to install in "editable" or "develop" mode, which I consider necessary for the development of this package.
Use a light-weight setup.py instead.
--- python/PACKAGE.rst | 23 +++++++++++++++++++++++ python/setup.cfg | 18 ++++++++++++++++++ python/setup.py | 23 +++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 python/PACKAGE.rst create mode 100755 python/setup.cfg create mode 100755 python/setup.py
python/PACKAGE.rst new file +23 -0
@@ -0,0 +1,23 @@ +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.core`` subpackage offers rudimentary facilities for launching +QEMU and communicating with it via QMP. Refer to the module documentation +(``>>> help(qemu.core)``) for more information. + +Contributing +------------ + +This package is maintained by John Snow <[email protected]> as part of +the QEMU source tree. Contributions are welcome and follow the `QEMU +patch submission process +<https://wiki.qemu.org/Contribute/SubmitAPatch>`_. There is a `Gitlab +mirror <https://gitlab.com/jsnow/qemu/-/tree/python>`_, but +contributions must be sent to the list for inclusion.
python/setup.cfg new file +18 -0
@@ -0,0 +1,18 @@ +[metadata] +name = qemu +maintainer = QEMU Developer Team +maintainer_email = [email protected] +url = https://www.qemu.org/ +download_url = https://www.qemu.org/download/ +description = QEMU Python Build, Debug and SDK tooling. +long_description = file:PACKAGE.rst +long_description_content_type = text/x-rst +classifiers = + Development Status :: 3 - Alpha + License :: OSI Approved :: GNU General Public License v2 (GPLv2) + Natural Language :: English + Operating System :: OS Independent + +[options] +python_requires = >= 3.6 +packages = find_namespace:
python/setup.py new file +23 -0
@@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +QEMU tooling installer script +Copyright (c) 2020 John Snow for Red Hat, Inc. +""" + +import setuptools +import pkg_resources + + +def main(): + """ + QEMU tooling installer + """ + + # https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108 + pkg_resources.require('setuptools>=39.2') + + setuptools.setup() + + +if __name__ == '__main__': + main()
Signature · 1 line
2.26.2
PATCH v2 3/15 python: add VERSION file
In reply to John SnowPython infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible to my knowledge.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python core tooling synchronizes with the QEMU version directly (5.2.0, 5.1.1, 5.3.0, etc.)
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
i.e., "qemu.core" will always remain in lock-step with QEMU.
- We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp and begin indepedently versioning such a package separately from the QEMU version it accompanies.
Implement this versioning scheme by adding a VERSION file and setting it to 5.2.0a1.
--- python/VERSION | 1 + python/setup.cfg | 1 + 2 files changed, 2 insertions(+) create mode 100644 python/VERSION
python/VERSION new file +1 -0
@@ -0,0 +1 @@ +5.2.0a1
python/setup.cfg +1 -0
@@ -1,5 +1,6 @@ [metadata] name = qemu +version = file:VERSION maintainer = QEMU Developer Team maintainer_email = [email protected] url = https://www.qemu.org/
Signature · 1 line
2.26.2
Re: [PATCH v2 03/15] python: add VERSION file
Quoted 10 lines · John Snow
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible to my knowledge.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
See also:
https://github.com/pypa/pip/issues/7549
https://github.com/pypa/pip/issues/7555
Quoted 58 lines
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python core tooling synchronizes with the QEMU version directly (5.2.0, 5.1.1, 5.3.0, etc.)
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
i.e., "qemu.core" will always remain in lock-step with QEMU.
- We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp and begin indepedently versioning such a package separately from the QEMU version it accompanies.
Implement this versioning scheme by adding a VERSION file and setting it to 5.2.0a1.
Signed-off-by John Snow <[email protected]>--- python/VERSION | 1 + python/setup.cfg | 1 + 2 files changed, 2 insertions(+)create mode 100644 python/VERSION
python/VERSION new file +1
-0@@ -0,0 +1 @@ +5.2.0a1python/setup.cfg +1
-0@@ -1,5 +1,6 @@ [metadata] name = qemu +version = file:VERSION maintainer = QEMU Developer Team maintainer_email = [email protected] url = https://www.qemu.org/
Re: [PATCH v2 03/15] python: add VERSION file
In reply to John SnowQuoted 32 lines · John Snow
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible to my knowledge.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python core tooling synchronizes with the QEMU version directly (5.2.0, 5.1.1, 5.3.0, etc.)
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
Quoted 5 lines
i.e., "qemu.core" will always remain in lock-step with QEMU.
- We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp and begin indepedently versioning such a package separately from the QEMU version it accompanies.
I think this need to be considered very carefully.
I'm not overly familiar with the Python ecosystem but it would appear that, despite PEP 440 not mandating this, many (most?) of the packages uploaded to PyPi are using semantic versioning.
With that in mind, I think it would be unwise for qemu.* not to do the same; in particular, using a version number that's not <1.0.0 for a package that is very much in flux will almost certainly break people's expectations, and is also not something that you can easily take back at a later time.
Signature · 1 line
Andrea Bolognani / Red Hat / Virtualization
Re: [PATCH v2 03/15] python: add VERSION file
Quoted 39 lines · Andrea Bolognani
Quoted 32 lines · John Snow
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible to my knowledge.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python core tooling synchronizes with the QEMU version directly (5.2.0, 5.1.1, 5.3.0, etc.)
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
Quoted 5 lines
i.e., "qemu.core" will always remain in lock-step with QEMU.
- We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp and begin indepedently versioning such a package separately from the QEMU version it accompanies.
Quoted 5 lines
I think this need to be considered very carefully.
I'm not overly familiar with the Python ecosystem but it would appear that, despite PEP 440 not mandating this, many (most?) of the packages uploaded to PyPi are using semantic versioning.
Semver is the recommended approach, but they explicitly list date based versioning as a valid alternative
"Semantic versioning is not a suitable choice for all projects,
such as those with a regular time based release cadence and a deprecation process that provides warnings for a number of releases prior to removal of a feature."
That paragraph describes QEMU's scenario.
NB, historically we've made arbitrary changes to the python code since it was not considered public API. If we make it official public API, then we would actually need to start following our deprecation process for the python code too.
Quoted 5 lines
With that in mind, I think it would be unwise for qemu.* not to do the same; in particular, using a version number that's not <1.0.0 for a package that is very much in flux will almost certainly break people's expectations, and is also not something that you can easily take back at a later time.
I don't think it is that big a deal, and there is clear benefit to having the python code version match the QEMU version that it is the companioon to.
Ultimately the versioning scheme just impacts on the version string conditionals people list for their dependancies. Apps consuming QEMU can handle any of the version schemes without much difference.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 03/15] python: add VERSION file
Quoted 56 lines · Daniel P. Berrangé
Quoted 39 lines · Andrea Bolognani
Quoted 32 lines · John Snow
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible to my knowledge.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python core tooling synchronizes with the QEMU version directly (5.2.0, 5.1.1, 5.3.0, etc.)
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 5.2.0a1, 5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
Quoted 5 lines
i.e., "qemu.core" will always remain in lock-step with QEMU.
- We reserve the right to split out e.g. qemu.core.qmp to qemu.qmp and begin indepedently versioning such a package separately from the QEMU version it accompanies.
Quoted 5 lines
I think this need to be considered very carefully.
I'm not overly familiar with the Python ecosystem but it would appear that, despite PEP 440 not mandating this, many (most?) of the packages uploaded to PyPi are using semantic versioning.
Semver is the recommended approach, but they explicitly list date based versioning as a valid alternative
"Semantic versioning is not a suitable choice for all projects,
such as those with a regular time based release cadence and a deprecation process that provides warnings for a number of releases prior to removal of a feature."
Quoted 7 lines
That paragraph describes QEMU's scenario.
NB, historically we've made arbitrary changes to the python code since it was not considered public API. If we make it official public API, then we would actually need to start following our deprecation process for the python code too.
I think our deprecation process is not tightly compatible with how Python programmers at-large expect packages to work. Semver is more or less the norm, despite the fact that it isn't explicitly required.
setting requirements in requirements.txt, setup.[cfg|py], Pipfile, etc often hinge on a major version, e.g.
qemu >= 5.0
qemu >= 3.0, < 6.0
would both be common forms of describing a requirement.
Pinning specific versions is considered bad form, but in the context of releasing a package, I often see maintainers hedging their bets and preventing upgrades across a major version line.
For that reason I am a little weary of adopting the deprecation policy as it exists in QEMU directly, and would propose a modification for my purposes here:
- Features must be marked as deprecated
- They must remain in a deprecated state for [at least] 2 releases
- Deprecated features may not be removed until a major version change.
In practice, this modification is a change from "2 releases" to "at least 2".
However, I didn't intend to pay any mind to the deprecation policy "yet", as I have the package metadata listing the package status as "Alpha", see below:
Quoted 10 lines
Quoted 5 lines
With that in mind, I think it would be unwise for qemu.* not to do the same; in particular, using a version number that's not <1.0.0 for a package that is very much in flux will almost certainly break people's expectations, and is also not something that you can easily take back at a later time.
I don't think it is that big a deal, and there is clear benefit to having the python code version match the QEMU version that it is the companioon to.
Do you think it's fine if I start versioning at, say, "0.5.2", I could ignore a deprecation policy for now? I have a lot of changes I want to make and expect a lot of breaking changes very quickly.
I just wanted to try -- somehow -- to conjure up a relationship to the QEMU package it's designed to work with.
Quoted 7 lines
Ultimately the versioning scheme just impacts on the version string conditionals people list for their dependancies. Apps consuming QEMU can handle any of the version schemes without much difference.
Regards,
Daniel
Thanks for your input. This is the trickiest part of the process for me.
I believe there is value in distributing these tools for other developers to help them prototype and experiment with new features, but realize it's a tightrope walk because we're flying dangerously close to providing a management utility that needs to care about cross-version compatibility and so on.
I have no interest in providing stringent cross-version compatibility, but at the same time, libraries like QMP are not really at risk of changing all that much, actually. It will *probably* work for most QEMU versions.
I have some further patches where I clean up the scripts in ./scripts/qmp and move them to ./python/qemu/qmp -- and that work is making me consider a rework to this series. I think that rework matches the spirit of an earlier suggestion of yours:
- move ./python/qemu/core/qmp.py to ./python/qemu/qmp/qmp.py
- (in a follow-up series) move ./scripts/qmp/* to ./python/qemu/qmp/*
- rename ./python/qemu/core/ to ./python/qemu/machine (move accel.py, machine.py and qtest.py to a 'machine' pkg.)
In effect, we'd then have:
qemu.machine -- primarily a test interface for QEMU instances qemu.qmp -- fairly ageless QMP tools/lib for talking to QEMU
and the different levels of support and "use at your own risk" become slightly more clear between the two packages.
--js
Re: [PATCH v2 03/15] python: add VERSION file
In reply to Daniel P. BerrangéQuoted 12 lines · Daniel P. Berrangé
Quoted 5 lines · Andrea Bolognani
I think this need to be considered very carefully.
I'm not overly familiar with the Python ecosystem but it would appear that, despite PEP 440 not mandating this, many (most?) of the packages uploaded to PyPi are using semantic versioning.
Semver is the recommended approach, but they explicitly list date based versioning as a valid alternative
Quoted 6 lines
"Semantic versioning is not a suitable choice for all projects,
such as those with a regular time based release cadence and a deprecation process that provides warnings for a number of releases prior to removal of a feature."That paragraph describes QEMU's scenario.
The section on date based versioning continues with
A key advantage of date based versioning is that it is straightforward to tell how old the base feature set of a particular release is given just the version number.
Version numbers for date based projects typically take the form of YEAR.MONTH (for example, 12.04, 15.10).
The problem with QEMU's version numbers is that, while they are date based, they still *look* like semver, so it wouldn't be at all unreasonable for the user to expect that they also *behave* like semver.
This is not much of a problem when it comes to the main binary, but it is certainly much more confusing when you start using the same version number for a Python library.
Quoted 6 lines
Quoted 5 lines
With that in mind, I think it would be unwise for qemu.* not to do the same; in particular, using a version number that's not <1.0.0 for a package that is very much in flux will almost certainly break people's expectations, and is also not something that you can easily take back at a later time.
Quoted 7 lines
I don't think it is that big a deal, and there is clear benefit to having the python code version match the QEMU version that it is the companioon to.
Ultimately the versioning scheme just impacts on the version string conditionals people list for their dependancies. Apps consuming QEMU can handle any of the version schemes without much difference.
The problem comes from the expectations: a Python programmer, who is used to semver due to its prominence on PyPi, when deciding whether to move from qemu.core 4.2.0 to 5.0.0 might expect to need code changes to cope with API-breaking changes - where in fact there are none, and at the same time might expect upgrading to 5.2.0 from 5.0.0 to be completely straightforward when in reality a feature their application depends on might have been removed after the usual deprecation period.
Signature · 1 line
Andrea Bolognani / Red Hat / Virtualization
Re: [PATCH v2 03/15] python: add VERSION file
Quoted 16 lines · Andrea Bolognani
Quoted 7 lines · Daniel P. Berrangé
Quoted 5 lines · Andrea Bolognani
With that in mind, I think it would be unwise for qemu.* not to do the same; in particular, using a version number that's not <1.0.0 for a package that is very much in flux will almost certainly break people's expectations, and is also not something that you can easily take back at a later time.
Quoted 7 lines
I don't think it is that big a deal, and there is clear benefit to having the python code version match the QEMU version that it is the companioon to.
Ultimately the versioning scheme just impacts on the version string conditionals people list for their dependancies. Apps consuming QEMU can handle any of the version schemes without much difference.
Quoted 8 lines
The problem comes from the expectations: a Python programmer, who is used to semver due to its prominence on PyPi, when deciding whether to move from qemu.core 4.2.0 to 5.0.0 might expect to need code changes to cope with API-breaking changes - where in fact there are none, and at the same time might expect upgrading to 5.2.0 from 5.0.0 to be completely straightforward when in reality a feature their application depends on might have been removed after the usual deprecation period.
The QEMU python modules are not like other python modules though, precisely because they are talking to QEMU. If we are shipping QEMU python releases on the same schedule as QEMU, then we can expect the normal ase to be updating both QEMU & Python together. So regardless of versioning in the python code, the QMP code they are talking to is liable to have removed deprecated features they are using. IMHO the upgrade issue is largely a problem of docs and testing, semver is no magic bullet.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 03/15] python: add VERSION file
Quoted 4 lines · Daniel P. Berrangé
The QEMU python modules are not like other python modules though, precisely because they are talking to QEMU. If we are shipping QEMU python releases on the same schedule as QEMU, then we can expect the normal ase to be updating both QEMU & Python together.
Once you start uploading the Python packages to PyPi, you really have no way to ensure this will be the case.
Signature · 1 line
Andrea Bolognani / Red Hat / Virtualization
PATCH v2 4/15 python: add directory structure README.rst files
In reply to John SnowAdd short readmes to python/, python/qemu/, and python/qemu/core that explain the directory hierarchy. These readmes are visible when browsing the source on e.g. gitlab/github and are designed to help new developers/users quickly make sense of the source tree.
They are not designed for inclusion in a published manual.
--- python/README.rst | 27 +++++++++++++++++++++++++++ python/qemu/README.rst | 8 ++++++++ python/qemu/core/README.rst | 9 +++++++++ 3 files changed, 44 insertions(+) create mode 100644 python/README.rst create mode 100644 python/qemu/README.rst create mode 100644 python/qemu/core/README.rst
python/README.rst new file +27 -0
@@ -0,0 +1,27 @@ +QEMU Python Tooling +=================== + +This directory houses Python tooling used by the QEMU project to build, +configure, and test QEMU. It is organized by namespace (``qemu``), and +then by package (``qemu/core``). + +``setup.py`` is used by ``pip`` to install this tooling to the current +environment. You will generally invoke it by doing one of the following: + +1. ``pip3 install .`` will install these packages to your current + environment. If you are inside a virtual environment, they will + install there. If you are not, it will attempt to install to the + global environment, which is not recommended. + +2. ``pip3 install --user .`` will install these packages to your user's + local python packages. If you are inside of a virtual environment, + this will fail. + +If you amend the ``-e`` argument, pip will install in "editable" mode; +which installs a version of the package that uses symlinks to these +files, such that the package always reflects the latest version in your +git tree. + +See `Installing packages using pip and virtual environments +<https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`_ +for more information.
python/qemu/README.rst new file +8 -0
@@ -0,0 +1,8 @@ +QEMU Python Namespace +===================== + +This directory serves as the root of a `Python PEP 420 implicit +namespace package <<https://www.python.org/dev/peps/pep-0420/>`_. + +Each directory below is assumed to be an installable Python package that +is available under the ``qemu.<package>`` namespace.
python/qemu/core/README.rst new file +9 -0
@@ -0,0 +1,9 @@ +qemu.core Package +================= + +This package provides core utilities used for testing and debugging +QEMU. It is used by the iotests, vm tests, and several other utilities +in the ./scripts directory. It is not a fully-fledged SDK and it is +subject to change at any time. + +See the documentation in ``__init__.py`` for more information.
Signature · 1 line
2.26.2
Re: [PATCH v2 04/15] python: add directory structure README.rst files
Quoted 2 lines · John Snow
Add short readmes to python/, python/qemu/, and python/qemu/core that explain the directory hierarchy. These readmes are visible when browsing
Maybe readmes -> READMEs
Otherwise:
Quoted 14 lines
the source on e.g. gitlab/github and are designed to help new developers/users quickly make sense of the source tree.
They are not designed for inclusion in a published manual.
Signed-off-by John Snow <[email protected]>--- python/README.rst | 27 +++++++++++++++++++++++++++ python/qemu/README.rst | 8 ++++++++ python/qemu/core/README.rst | 9 +++++++++ 3 files changed, 44 insertions(+)create mode 100644
python/README.rst
create mode 100644python/qemu/README.rst
create mode 100644python/qemu/core/README.rst
Re: [PATCH v2 04/15] python: add directory structure README.rst files
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 2 lines · John Snow
Add short readmes to python/, python/qemu/, and python/qemu/core that explain the directory hierarchy. These readmes are visible when browsing
Maybe readmes -> READMEs
If you want it to match the filename, "README files".
--js
Quoted 18 lines
Otherwise:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 14 lines
the source on e.g. gitlab/github and are designed to help new developers/users quickly make sense of the source tree.
They are not designed for inclusion in a published manual.
Signed-off-by John Snow <[email protected]>---
python/README.rst | 27 +++++++++++++++++++++++++++ python/qemu/README.rst | 8 ++++++++python/qemu/core/README.rst| 9 +++++++++3 files changed, 44 insertions(+)create mode 100644
python/README.rst
create mode 100644python/qemu/README.rst
create mode 100644python/qemu/core/README.rst
PATCH v2 5/15 python: Add pipenv support
In reply to John Snowpipenv is a tool used for managing virtual environments with pinned, explicit dependencies. It is used for precisely recreating python virtual environments.
pipenv uses two files to do this:
(1) Pipfile, which is similar in purpose and scope to what setup.py lists. It specifies the requisite minimum to get a functional environment for using this package.
(2) Pipfile.lock, which is similar in purpose to pip freeze > requirements.txt. It specifies a canonical virtual environment used for deployment or testing. This ensures that all users have repeatable results.
The primary benefit of using this tool is to ensure repeatable CI results with a known set of packages. Although I endeavor to support as many versions as I can, the fluid nature of the Python toolchain often means tailoring code for fairly specific versions.
Note that pipenv is *not* required to install or use this module; this is purely for the sake of repeatable testing by CI or developers.
Here, a "blank" pipfile is added with no dependencies, but specifies Python 3.6 for the virtual environment.
Pipfile will specify our version minimums, while Pipfile.lock specifies an exact loudout of packages that were known to operate correctly. This latter file provides the real value for easy setup of container images and CI environments.
--- python/Pipfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 python/Pipfile
python/Pipfile new file +11 -0
@@ -0,0 +1,11 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] + +[requires] +python_version = "3.6"
Signature · 1 line
2.26.2
PATCH v2 6/15 python: add pylint exceptions to __init__.py
In reply to John SnowPylint 2.5.x and 2.6.x have regressions that make import checking inconsistent, see:
https: //github.com/PyCQA/pylint/issues/3609
https: //github.com/PyCQA/pylint/issues/3624
https: //github.com/PyCQA/pylint/issues/3651
--- python/qemu/core/__init__.py | 3 +++ 1 file changed, 3 insertions(+)
python/qemu/core/__init__.py +3 -0
@@ -27,6 +27,9 @@ # the COPYING file in the top-level directory. # +# pylint: disable=import-error +# see: https://github.com/PyCQA/pylint/issues/3624 +# see: https://github.com/PyCQA/pylint/issues/3651 from .accel import kvm_available, list_accel, tcg_available from .machine import QEMUMachine from .qmp import QEMUMonitorProtocol
Signature · 1 line
2.26.2
PATCH v2 7/15 python: move pylintrc into setup.cfg
In reply to John SnowDelete the empty settings now that it's sharing a home with settings for other tools.
pylint can now be run from this folder as "pylint qemu".
--- python/qemu/core/pylintrc | 58 --------------------------------------- python/setup.cfg | 29 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 58 deletions(-) delete mode 100644 python/qemu/core/pylintrc
python/qemu/core/pylintrc deleted +0 -58
@@ -1,58 +0,0 @@ -[MASTER] - -[MESSAGES CONTROL] - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=too-many-arguments, - too-many-instance-attributes, - too-many-public-methods, - -[REPORTS] - -[REFACTORING] - -[MISCELLANEOUS] - -[LOGGING] - -[BASIC] - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _, - fd, - c, -[VARIABLES] - -[STRING] - -[SPELLING] - -[FORMAT] - -[SIMILARITIES] - -# Ignore imports when computing similarities. -ignore-imports=yes - -[TYPECHECK] - -[CLASSES] - -[IMPORTS] - -[DESIGN] - -[EXCEPTIONS]
python/setup.cfg +29 -0
@@ -17,3 +17,32 @@ classifiers = [options] python_requires = >= 3.6 packages = find_namespace: + +[pylint.messages control] +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=too-many-arguments, + too-many-instance-attributes, + too-many-public-methods, + +[pylint.basic] +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _, + fd, + c, + +[pylint.similarities] +# Ignore imports when computing similarities. +ignore-imports=yes
Signature · 1 line
2.26.2
PATCH v2 8/15 python: add pylint to pipenv
In reply to John SnowWe are specifying >= pylint 2.6.x for two reasons:
1. For setup.cfg support, added in pylint 2.5.x
2. To clarify that we are using a version that has incompatibly dropped bad-whitespace checks.
--- python/Pipfile | 1 + python/Pipfile.lock | 127 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 python/Pipfile.lock
python/Pipfile +1 -0
@@ -4,6 +4,7 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] +pylint = ">=2.6.0" [packages]
python/Pipfile.lock new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 9/15 python: move flake8 config to setup.cfg
In reply to John Snow--- python/qemu/core/.flake8 | 2 -- python/setup.cfg | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 python/qemu/core/.flake8
python/qemu/core/.flake8 deleted +0 -2
@@ -1,2 +0,0 @@ -[flake8] -extend-ignore = E722 # Pylint handles this, but smarter.
python/setup.cfg +3 -0
@@ -18,6 +18,9 @@ classifiers = python_requires = >= 3.6 packages = find_namespace: +[flake8] +extend-ignore = E722 # Pylint handles this, but smarter. + [pylint.messages control] # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifiers separated by comma (,) or put this
Signature · 1 line
2.26.2
PATCH v2 10/15 python: Add flake8 to pipenv
In reply to John Snowflake8 3.5.x does not support the --extend-ignore syntax used in the .flake8 file to gracefully extend default ignores, so 3.6.x is our minimum requirement. There is no known upper bound.
flake8 can be run from the python/ directory with no arguments.
--- python/Pipfile | 1 + python/Pipfile.lock | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-)
python/Pipfile +1 -0
@@ -4,6 +4,7 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] +flake8 = ">=3.6.0" pylint = ">=2.6.0" [packages]
python/Pipfile.lock +41 -1
66 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 11/15 python: move mypy.ini into setup.cfg
In reply to John Snowmypy supports reading its configuration values from a central project configuration file; do so.
--- python/mypy.ini | 4 ---- python/setup.cfg | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 python/mypy.ini
python/mypy.ini deleted +0 -4
@@ -1,4 +0,0 @@ -[mypy] -strict = True -python_version = 3.6 -warn_unused_configs = True
python/setup.cfg +5 -0
@@ -21,6 +21,11 @@ packages = find_namespace: [flake8] extend-ignore = E722 # Pylint handles this, but smarter. +[mypy] +strict = True +python_version = 3.6 +warn_unused_configs = True + [pylint.messages control] # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifiers separated by comma (,) or put this
Signature · 1 line
2.26.2
PATCH v2 12/15 python: add mypy to pipenv
In reply to John Snow0.730 appears to be about the oldest version that works with the features we want, including nice human readable output (to make sure iotest 297 passes), and type-parameterized Popen generics.
0.770, however, supports adding 'strict' to the config file, so require at least 0.770.
mypy can be run from the python root by typing 'mypy qemu'.
--- python/Pipfile | 1 + python/Pipfile.lock | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-)
python/Pipfile +1 -0
@@ -5,6 +5,7 @@ verify_ssl = true [dev-packages] flake8 = ">=3.6.0" +mypy = ">=0.770" pylint = ">=2.6.0" [packages]
python/Pipfile.lock +36 -1
@@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "9f6d4857a6c72ad40fc1ec1e58cdb76f187a2986ac4156f0027e5eb798ec69a9" + "sha256": "65f010a8f2e55e9870d2b7e0d8af129516097d23abf2504f396552748b067ade" }, "pipfile-spec": 6, "requires": {
@@ -83,6 +83,33 @@ ], "version": "==0.6.1" }, + "mypy": { + "hashes": [ + "sha256:0a0d102247c16ce93c97066443d11e2d36e6cc2a32d8ccc1f705268970479324", + "sha256:0d34d6b122597d48a36d6c59e35341f410d4abfa771d96d04ae2c468dd201abc", + "sha256:2170492030f6faa537647d29945786d297e4862765f0b4ac5930ff62e300d802", + "sha256:2842d4fbd1b12ab422346376aad03ff5d0805b706102e475e962370f874a5122", + "sha256:2b21ba45ad9ef2e2eb88ce4aeadd0112d0f5026418324176fd494a6824b74975", + "sha256:72060bf64f290fb629bd4a67c707a66fd88ca26e413a91384b18db3876e57ed7", + "sha256:af4e9ff1834e565f1baa74ccf7ae2564ae38c8df2a85b057af1dbbc958eb6666", + "sha256:bd03b3cf666bff8d710d633d1c56ab7facbdc204d567715cb3b9f85c6e94f669", + "sha256:c614194e01c85bb2e551c421397e49afb2872c88b5830e3554f0519f9fb1c178", + "sha256:cf4e7bf7f1214826cf7333627cb2547c0db7e3078723227820d0a2490f117a01", + "sha256:da56dedcd7cd502ccd3c5dddc656cb36113dd793ad466e894574125945653cea", + "sha256:e86bdace26c5fe9cf8cb735e7cedfe7850ad92b327ac5d797c656717d2ca66de", + "sha256:e97e9c13d67fbe524be17e4d8025d51a7dca38f90de2e462243ab8ed8a9178d1", + "sha256:eea260feb1830a627fb526d22fbb426b750d9f5a47b624e8d5e7e004359b219c" + ], + "index": "pypi", + "version": "==0.790" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, "pycodestyle": { "hashes": [ "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367",
@@ -149,6 +176,14 @@ "markers": "implementation_name == 'cpython' and python_version < '3.8'", "version": "==1.4.1" }, + "typing-extensions": { + "hashes": [ + "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918", + "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c", + "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f" + ], + "version": "==3.7.4.3" + }, "wrapt": { "hashes": [ "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
Signature · 1 line
2.26.2
PATCH v2 13/15 python: move .isort.cfg into setup.cfg
In reply to John Snow--- python/.isort.cfg | 7 ------- python/setup.cfg | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 python/.isort.cfg
python/.isort.cfg deleted +0 -7
@@ -1,7 +0,0 @@ -[settings] -force_grid_wrap=4 -force_sort_within_sections=True -include_trailing_comma=True -line_length=72 -lines_after_imports=2 -multi_line_output=3
python/setup.cfg +8 -0
@@ -54,3 +54,11 @@ good-names=i, [pylint.similarities] # Ignore imports when computing similarities. ignore-imports=yes + +[isort] +force_grid_wrap=4 +force_sort_within_sections=True +include_trailing_comma=True +line_length=72 +lines_after_imports=2 +multi_line_output=3
Signature · 1 line
2.26.2
Re: [PATCH v2 13/15] python: move .isort.cfg into setup.cfg
Quoted 5 lines · John Snow
Signed-off-by John Snow <[email protected]>--- python/.isort.cfg | 7 ------- python/setup.cfg | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-)
PATCH v2 14/15 python/qemu: add isort to pipenv
In reply to John Snowisort 5.0.0 through 5.0.4 has a bug that causes it to misinterpret certain "from ..." clauses that are not related to imports.
Require 5.0.5 or greater.
isort can be run with 'isort -c qemu' from the python root.
--- python/Pipfile | 1 + python/Pipfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
python/Pipfile +1 -0
@@ -5,6 +5,7 @@ verify_ssl = true [dev-packages] flake8 = ">=3.6.0" +isort = ">=5.0.5" mypy = ">=0.770" pylint = ">=2.6.0"
python/Pipfile.lock +2 -2
@@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "65f010a8f2e55e9870d2b7e0d8af129516097d23abf2504f396552748b067ade" + "sha256": "b89c7a1b8a414f2a4cd708964123fb427d55419ee0b39e088bf2e7d4fbc11979" }, "pipfile-spec": 6, "requires": {
@@ -46,7 +46,7 @@ "sha256:dcab1d98b469a12a1a624ead220584391648790275560e1a43e54c5dceae65e7", "sha256:dcaeec1b5f0eca77faea2a35ab790b4f3680ff75590bfcb7145986905aab2f58" ], - "markers": "python_version >= '3.6' and python_version < '4.0'", + "index": "pypi", "version": "==5.6.4" }, "lazy-object-proxy": {
Signature · 1 line
2.26.2
PATCH v2 15/15 python/qemu: add qemu package itself to pipenv
In reply to John SnowThis adds the python qemu packages themselves to the pipenv manifest. 'pipenv sync' will create a virtual environment sufficient to use the SDK. 'pipenv sync --dev' will create a virtual environment sufficient to use and test the SDK (with pylint, mypy, isort, flake8, etc.)
The qemu packages are installed in 'editable' mode; all changes made to the python package inside the git tree will be reflected in the installed package without reinstallation. This includes changes made via git pull and so on.
--- python/Pipfile | 1 + python/Pipfile.lock | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
python/Pipfile +1 -0
@@ -10,6 +10,7 @@ mypy = ">=0.770" pylint = ">=2.6.0" [packages] +qemu = {editable = true,path = "."} [requires] python_version = "3.6"
python/Pipfile.lock +7 -2
@@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "b89c7a1b8a414f2a4cd708964123fb427d55419ee0b39e088bf2e7d4fbc11979" + "sha256": "e38d142c3fadc2f2ed849e86f7ebd14e25974dc12228751490aef5a9ee074f2f" }, "pipfile-spec": 6, "requires": {
@@ -15,7 +15,12 @@ } ] }, - "default": {}, + "default": { + "qemu": { + "editable": true, + "path": "." + } + }, "develop": { "astroid": { "hashes": [
Signature · 1 line
2.26.2