Use known good releases when installing in pyvenv
cover Use known good releases when installing in pyvenv
This series introduce a new installation command for mkvenv.py that retrieves the packages to be installed from a TOML file. This allows being more flexible in using the system version of a package, while at the same time using a known-good version when installing the package. This is important for packages that sometimes have backwards-incompatible changes or that depend on specific versions of their dependencies.
For example, in the case of sphinx we can always use the last version that supports older versions of Python and especially docutils (Ubuntu 20.04 for example would not support sphinx 6.0), and in the case of Avocado we can avoid installing a package that conflicts with any plugins already existing in the system package path. This in turn enables using the same virtual environment for both the build and qemu-iotests. John has patches for this.
For the configuration file, TOML was chosen because it was more human readable and easier to edit than JSON. A parser is available in the Python 3.11 standard library; for older versions, the API-compatible replacement tomli is very small (12k). I am introducing it as a vendored .whl file because it is not installed by default in most distros (unlike pip and setuptools which were introduced in 8.0) and because Debian 11 only has it in bullseye-backports. However, if preferred the patch "python: use vendored tomli" can be dropped. In that case, tomli will have to be installed from either PyPI or bullseye-backports.
While tomli is bundled with pip, this is only true of recent versions of pip. Of all the supported OSes pretty much only FreeBSD has a recent enough version of pip while staying on Python <3.11. So we cannot use the same trick that is in place for distlib.
In order to pick the tomli mapping, lcitool is updated to a recent version. As a side effect this updates from LEAP 15.4 to 15.5.
Paolo
Paolo Bonzini (9):
python: mkvenv: tweak the matching of --diagnose to depspecs
python: mkvenv: introduce TOML-like representation of dependencies
python: mkvenv: add ensuregroup command
lcitool: bump libvirt-ci submodule and regenerate
configure: never use PyPI for Meson
python: use vendored tomli
configure: switch to ensuregroup
Revert "tests: Use separate virtual environment for avocado" tests/docker: add python3-tomli dependency to containers
.gitlab-ci.d/buildtest.yml | 6 +- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- configure | 22 +- docs/devel/acpi-bits.rst | 6 +- docs/devel/testing.rst | 14 +- python/scripts/mkvenv.py | 201 ++++++++++++++++-- python/scripts/vendor.py | 5 +- python/setup.cfg | 9 + python/wheels/tomli-2.0.1-py3-none-any.whl | Bin 0 -> 12757 bytes pythondeps.toml | 32 +++ .../org.centos/stream/8/x86_64/test-avocado | 4 +- scripts/device-crash-test | 2 +- tests/Makefile.include | 19 +- tests/docker/dockerfiles/centos8.docker | 3 +- .../dockerfiles/debian-all-test-cross.docker | 7 +- .../dockerfiles/debian-amd64-cross.docker | 6 +- tests/docker/dockerfiles/debian-amd64.docker | 4 + .../dockerfiles/debian-arm64-cross.docker | 6 +- .../dockerfiles/debian-armel-cross.docker | 6 +- .../dockerfiles/debian-armhf-cross.docker | 6 +- .../dockerfiles/debian-hexagon-cross.docker | 6 +- .../dockerfiles/debian-mips64el-cross.docker | 6 +- .../dockerfiles/debian-mipsel-cross.docker | 6 +- .../dockerfiles/debian-ppc64el-cross.docker | 6 +- .../dockerfiles/debian-riscv64-cross.docker | 2 +- .../dockerfiles/debian-s390x-cross.docker | 6 +- .../dockerfiles/debian-tricore-cross.docker | 2 + .../dockerfiles/fedora-i386-cross.docker | 1 + .../dockerfiles/fedora-win32-cross.docker | 2 +- .../dockerfiles/fedora-win64-cross.docker | 2 +- tests/docker/dockerfiles/opensuse-leap.docker | 23 +- tests/docker/dockerfiles/ubuntu2004.docker | 4 +- tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/libvirt-ci | 2 +- tests/lcitool/mappings.yml | 27 ++- tests/lcitool/projects/qemu.yml | 3 +- tests/lcitool/targets/opensuse-leap-15.yml | 4 +- tests/requirements.txt | 6 - tests/vm/Makefile.include | 2 +- tests/vm/generated/freebsd.json | 1 + 41 files changed, 371 insertions(+), 103 deletions(-) create mode 100644 python/wheels/tomli-2.0.1-py3-none-any.whl create mode 100644 pythondeps.toml delete mode 100644 tests/requirements.txt
Signature · 1 line
2.41.0
PATCH 1/9 python: mkvenv: tweak the matching of --diagnose to depspecs
Move the matching between the "absent" array and dep_specs[0] inside the loop, preparing for the possibility of having multiple canaries among the installed packages.
--- python/scripts/mkvenv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
python/scripts/mkvenv.py +4 -1
@@ -806,6 +806,7 @@ def _do_ensure( """ absent = [] present = [] + canary = None for spec in dep_specs: matcher = distlib.version.LegacyMatcher(spec) ver = _get_version(matcher.name)
@@ -817,6 +818,8 @@ def _do_ensure( or not matcher.match(distlib.version.LegacyVersion(ver)) ): absent.append(spec) + if spec == dep_specs[0]: + canary = prog else: logger.info("found %s %s", matcher.name, ver) present.append(matcher.name)
@@ -839,7 +842,7 @@ def _do_ensure( absent[0], online, wheels_dir, - prog if absent[0] == dep_specs[0] else None, + canary, ) return None
Signature · 1 line
2.41.0
PATCH 2/9 python: mkvenv: introduce TOML-like representation of dependencies
In reply to Paolo BonziniWe would like to place all Python dependencies in the same file, so that we can add more information without having long and complex command lines. The plan is to have a TOML file with one entry per package, for example
[avocado]
avocado-framework = {
accepted = "(>=88.1, <93.0)",
installed = "88.1",
canary = "avocado"
}Each TOML section will thus be a dictionary of dictionaries. Modify mkvenv.py's workhorse function, _do_ensure, to already operate on such a data structure. The "ensure" subcommand is modified to separate the depspec into a name and a version part, and use the result (plus the --diagnose argument) to build a dictionary for each command line argument.
--- python/scripts/mkvenv.py | 77 +++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 16 deletions(-)
python/scripts/mkvenv.py +61 -16
@@ -46,6 +46,9 @@ """ +# The duplication between importlib and pkg_resources does not help +# pylint: disable=too-many-lines + # Copyright (C) 2022-2023 Red Hat, Inc. # # Authors:
@@ -69,6 +72,7 @@ from types import SimpleNamespace from typing import ( Any, + Dict, Iterator, Optional, Sequence,
@@ -786,43 +790,67 @@ def pip_install( ) +def _make_version_constraint(info: Dict[str, str], install: bool) -> str: + """ + Construct the version constraint part of a PEP 508 dependency + specification (for example '>=0.61.5') from the accepted and + installed keys of the provided dictionary. + + :param info: A dictionary corresponding to a TOML key-value list. + :param install: True generates install constraints, False generates + presence constraints + """ + if install and "installed" in info: + return "==" + info["installed"] + + dep_spec = info.get("accepted", "") + dep_spec = dep_spec.strip() + # Double check that they didn't just use a version number + if dep_spec and dep_spec[0] not in "!~><=(": + raise Ouch( + "invalid dependency specifier " + dep_spec + " in dependency file" + ) + + return dep_spec + + def _do_ensure( - dep_specs: Sequence[str], + group: Dict[str, Dict[str, str]], online: bool = False, wheels_dir: Optional[Union[str, Path]] = None, - prog: Optional[str] = None, ) -> Optional[Tuple[str, bool]]: """ - Use pip to ensure we have the package specified by @dep_specs. + Use pip to ensure we have the packages specified in @group. - If the package is already installed, do nothing. If online and + If the packages are already installed, do nothing. If online and wheels_dir are both provided, prefer packages found in wheels_dir first before connecting to PyPI. - :param dep_specs: - PEP 508 dependency specifications. e.g. ['meson>=0.61.5']. + :param group: A dictionary of dictionaries, corresponding to a + section in a pythondeps.toml file. :param online: If True, fall back to PyPI. :param wheels_dir: If specified, search this path for packages. """ absent = [] present = [] canary = None - for spec in dep_specs: - matcher = distlib.version.LegacyMatcher(spec) - ver = _get_version(matcher.name) + for name, info in group.items(): + constraint = _make_version_constraint(info, False) + matcher = distlib.version.LegacyMatcher(name + constraint) + ver = _get_version(name) if ( ver is None # Always pass installed package to pip, so that they can be # updated if the requested version changes - or not _is_system_package(matcher.name) + or not _is_system_package(name) or not matcher.match(distlib.version.LegacyVersion(ver)) ): - absent.append(spec) - if spec == dep_specs[0]: - canary = prog + absent.append(name + _make_version_constraint(info, True)) + if len(absent) == 1: + canary = info.get("canary", None) else: - logger.info("found %s %s", matcher.name, ver) - present.append(matcher.name) + logger.info("found %s %s", name, ver) + present.append(name) if present: generate_console_scripts(present)
@@ -875,7 +903,24 @@ def ensure( if not HAVE_DISTLIB: raise Ouch("a usable distlib could not be found, please install it") - result = _do_ensure(dep_specs, online, wheels_dir, prog) + # Convert the depspecs to a dictionary, as if they came + # from a section in a pythondeps.toml file + group: Dict[str, Dict[str, str]] = {} + for spec in dep_specs: + name = distlib.version.LegacyMatcher(spec).name + group[name] = {} + + spec = spec.strip() + pos = len(name) + ver = spec[pos:].strip() + if ver: + group[name]["accepted"] = ver + + if prog: + group[name]["canary"] = prog + prog = None + + result = _do_ensure(group, online, wheels_dir) if result: # Well, that's not good. if result[1]:
Signature · 1 line
2.41.0
PATCH 3/9 python: mkvenv: add ensuregroup command
In reply to Paolo BonziniIntroduce a new subcommand that retrieves the packages to be installed from a TOML file. This allows being more flexible in using the system version of a package, while at the same time using a known-good version when installing the package. This is important for packages that sometimes have backwards-incompatible changes or that depend on specific versions of their dependencies.
Compared to JSON, TOML is more human readable and easier to edit. A parser is available in 3.11 but also available as a small (12k) package for older versions, tomli. While tomli is bundled with pip, this is only true of recent versions of pip. Of all the supported OSes pretty much only FreeBSD has a recent enough version of pip while staying on Python <3.11. So we cannot use the same trick that is in place for distlib.
--- python/scripts/mkvenv.py | 126 ++++++++++++++++++++++++++++++++++++++- python/setup.cfg | 9 +++ pythondeps.toml | 17 ++++++ 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 pythondeps.toml
python/scripts/mkvenv.py +125 -1
@@ -14,6 +14,8 @@ post_init post-venv initialization ensure Ensure that the specified package is installed. + ensuregroup + Ensure that the specified package group is installed. --------------------------------------------------
@@ -44,6 +46,19 @@ --online Install packages from PyPI, if necessary. --dir DIR Path to vendored packages where we may install from. +-------------------------------------------------- + +usage: mkvenv ensuregroup [-h] [--online] [--dir DIR] file group... + +positional arguments: + file pointer to a TOML file + group section name in the TOML file + +options: + -h, --help show this help message and exit + --online Install packages from PyPI, if necessary. + --dir DIR Path to vendored packages where we may install from. + """ # The duplication between importlib and pkg_resources does not help
@@ -99,6 +114,18 @@ except ImportError: HAVE_DISTLIB = False +# Try to load tomllib, with a fallback to tomli. +# HAVE_TOMLLIB is checked below, just-in-time, so that mkvenv does not fail +# outside the venv or before a potential call to ensurepip in checkpip(). +HAVE_TOMLLIB = True +try: + import tomllib +except ImportError: + try: + import tomli as tomllib + except ImportError: + HAVE_TOMLLIB = False + # Do not add any mandatory dependencies from outside the stdlib: # This script *must* be usable standalone!
@@ -837,6 +864,7 @@ def _do_ensure( for name, info in group.items(): constraint = _make_version_constraint(info, False) matcher = distlib.version.LegacyMatcher(name + constraint) + print(f"mkvenv: checking for {matcher}", file=sys.stderr) ver = _get_version(name) if ( ver is None
@@ -898,7 +926,6 @@ def ensure( be presented to the user. e.g., 'sphinx-build' can be used as a bellwether for the presence of 'sphinx'. """ - print(f"mkvenv: checking for {', '.join(dep_specs)}", file=sys.stderr) if not HAVE_DISTLIB: raise Ouch("a usable distlib could not be found, please install it")
@@ -928,6 +955,64 @@ def ensure( raise SystemExit(f"\n{result[0]}\n\n") +def _parse_groups(file: str) -> Dict[str, Dict[str, Any]]: + if not HAVE_TOMLLIB: + if sys.version_info < (3, 11): + raise Ouch("found no usable tomli, please install it") + + raise Ouch( + "Python >=3.11 does not have tomllib... what have you done!?" + ) + + try: + # Use loads() to support both tomli v1.2.x (Ubuntu 22.04, + # Debian bullseye-backports) and v2.0.x + with open(file, "r", encoding="ascii") as depfile: + contents = depfile.read() + return tomllib.loads(contents) # type: ignore + except tomllib.TOMLDecodeError as exc: + raise Ouch(f"parsing {file} failed: {exc}") from exc + + +def ensure_group( + file: str, + groups: Sequence[str], + online: bool = False, + wheels_dir: Optional[Union[str, Path]] = None, +) -> None: + """ + Use pip to ensure we have the package specified by @dep_specs. + + If the package is already installed, do nothing. If online and + wheels_dir are both provided, prefer packages found in wheels_dir + first before connecting to PyPI. + + :param dep_specs: + PEP 508 dependency specifications. e.g. ['meson>=0.61.5']. + :param online: If True, fall back to PyPI. + :param wheels_dir: If specified, search this path for packages. + """ + + if not HAVE_DISTLIB: + raise Ouch("found no usable distlib, please install it") + + parsed_deps = _parse_groups(file) + + to_install: Dict[str, Dict[str, str]] = {} + for group in groups: + try: + to_install.update(parsed_deps[group]) + except KeyError as exc: + raise Ouch(f"group {group} not defined") from exc + + result = _do_ensure(to_install, online, wheels_dir) + if result: + # Well, that's not good. + if result[1]: + raise Ouch(result[0]) + raise SystemExit(f"\n{result[0]}\n\n") + + def post_venv_setup() -> None: """ This is intended to be run *inside the venv* after it is created.
@@ -955,6 +1040,37 @@ def _add_post_init_subcommand(subparsers: Any) -> None: subparsers.add_parser("post_init", help="post-venv initialization") +def _add_ensuregroup_subcommand(subparsers: Any) -> None: + subparser = subparsers.add_parser( + "ensuregroup", + help="Ensure that the specified package group is installed.", + ) + subparser.add_argument( + "--online", + action="store_true", + help="Install packages from PyPI, if necessary.", + ) + subparser.add_argument( + "--dir", + type=str, + action="store", + help="Path to vendored packages where we may install from.", + ) + subparser.add_argument( + "file", + type=str, + action="store", + help=("Path to a TOML file describing package groups"), + ) + subparser.add_argument( + "group", + type=str, + action="store", + help="One or more package group names", + nargs="+", + ) + + def _add_ensure_subcommand(subparsers: Any) -> None: subparser = subparsers.add_parser( "ensure", help="Ensure that the specified package is installed."
@@ -1012,6 +1128,7 @@ def main() -> int: _add_create_subcommand(subparsers) _add_post_init_subcommand(subparsers) _add_ensure_subcommand(subparsers) + _add_ensuregroup_subcommand(subparsers) args = parser.parse_args() try:
@@ -1030,6 +1147,13 @@ def main() -> int: wheels_dir=args.dir, prog=args.diagnose, ) + if args.command == "ensuregroup": + ensure_group( + file=args.file, + groups=args.group, + online=args.online, + wheels_dir=args.dir, + ) logger.debug("mkvenv.py %s: exiting", args.command) except Ouch as exc: print("\n*** Ouch! ***\n", file=sys.stderr)
python/setup.cfg +9 -0
@@ -94,6 +94,12 @@ allow_subclassing_any = True [mypy-fuse] ignore_missing_imports = True +[mypy-tomli] +ignore_missing_imports = True + +[mypy-tomllib] +ignore_missing_imports = True + [mypy-urwid] ignore_missing_imports = True
@@ -130,6 +136,9 @@ ignore_missing_imports = True [mypy-pip._vendor.distlib.version] ignore_missing_imports = True +[mypy-pip._vendor.tomli] +ignore_missing_imports = 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
pythondeps.toml new file +17 -0
@@ -0,0 +1,17 @@ +# This file describes Python package requirements to be +# installed in the pyvenv Python virtual environment. +# +# Packages are placed in groups, which are installed using +# the ensuregroup subcommand of python/scripts/mkvenv.py. +# Each group forms a TOML section and each entry in the +# section is a TOML key-value list describing a package. +# All fields are optional; valid fields are: +# +# - accepted: accepted versions when using a system package +# - installed: fixed version to install in the virtual environment +# if a system package is not found; if not specified, +# the minimum and maximum +# - canary: if specified, use this program name to present more +# precise error diagnostics to the user. For example, +# 'sphinx-build' can be used as a bellwether for the +# presence of 'sphinx' in the system.
Signature · 1 line
2.41.0
PATCH 4/9 lcitool: bump libvirt-ci submodule and regenerate
In reply to Paolo BonziniThis brings in a newer version of the pipewire mapping, so rename it.
Python 3.9 and 3.10 do not seem to work in OpenSUSE LEAP 15.5 (weird, because 3.9 persisted from 15.3 to 15.4) so bump the Python runtime version to 3.11.
--- .../dockerfiles/debian-amd64-cross.docker | 2 +- .../dockerfiles/debian-arm64-cross.docker | 2 +- .../dockerfiles/debian-armel-cross.docker | 2 +- .../dockerfiles/debian-armhf-cross.docker | 2 +- .../dockerfiles/debian-mips64el-cross.docker | 2 +- .../dockerfiles/debian-mipsel-cross.docker | 2 +- .../dockerfiles/debian-ppc64el-cross.docker | 2 +- .../dockerfiles/debian-riscv64-cross.docker | 2 +- .../dockerfiles/debian-s390x-cross.docker | 2 +- .../dockerfiles/fedora-win32-cross.docker | 2 +- .../dockerfiles/fedora-win64-cross.docker | 2 +- tests/docker/dockerfiles/opensuse-leap.docker | 22 +++++++++---------- tests/lcitool/libvirt-ci | 2 +- tests/lcitool/mappings.yml | 12 +++++----- tests/lcitool/projects/qemu.yml | 2 +- tests/lcitool/targets/opensuse-leap-15.yml | 4 ++-- 16 files changed, 32 insertions(+), 32 deletions(-)
tests/docker/dockerfiles/debian-amd64-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross x86_64 debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch x86_64 debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-arm64-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross aarch64 debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch aarch64 debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-armel-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross armv6l debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch armv6l debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-armhf-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross armv7l debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch armv7l debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-mips64el-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross mips64el debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch mips64el debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-mipsel-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross mipsel debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch mipsel debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-ppc64el-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross ppc64le debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch ppc64le debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-riscv64-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross riscv64 debian-sid qemu-minimal +# $ lcitool dockerfile --layers all --cross-arch riscv64 debian-sid qemu-minimal # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/debian-s390x-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross s390x debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch s390x debian-11 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/fedora-win32-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross mingw32 fedora-38 qemu +# $ lcitool dockerfile --layers all --cross-arch mingw32 fedora-38 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/fedora-win64-cross.docker +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross mingw64 fedora-38 qemu +# $ lcitool dockerfile --layers all --cross-arch mingw64 fedora-38 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/docker/dockerfiles/opensuse-leap.docker +11 -11
@@ -4,7 +4,7 @@ # # https://gitlab.com/libvirt/libvirt-ci -FROM registry.opensuse.org/opensuse/leap:15.4 +FROM registry.opensuse.org/opensuse/leap:15.5 RUN zypper update -y && \ zypper install -y \
@@ -90,9 +90,9 @@ RUN zypper update -y && \ pcre-devel-static \ pipewire-devel \ pkgconfig \ - python39-base \ - python39-pip \ - python39-setuptools \ + python311-base \ + python311-pip \ + python311-setuptools \ rdma-core-devel \ sed \ snappy-devel \
@@ -125,18 +125,18 @@ RUN zypper update -y && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc -RUN /usr/bin/pip3.9 install \ - PyYAML \ - meson==0.63.2 \ - pillow \ - sphinx \ - sphinx-rtd-theme +RUN /usr/bin/pip3.11 install \ + PyYAML \ + meson==0.63.2 \ + pillow \ + sphinx \ + sphinx-rtd-theme ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make" ENV NINJA "/usr/bin/ninja" -ENV PYTHON "/usr/bin/python3.9" +ENV PYTHON "/usr/bin/python3.11" # As a final step configure the user (if env is defined) ARG USER ARG UID
tests/lcitool/libvirt-ci +1 -1
@@ -1 +1 @@ -Subproject commit 9bff3b763b5531a1490e238bfbf77306dc3a6dbb +Subproject commit bbd55b4d18cce8f89b5167675e434a6941315634
tests/lcitool/mappings.yml +6 -6
@@ -9,7 +9,7 @@ mappings: python3: CentOSStream8: python38 - OpenSUSELeap15: python39-base + OpenSUSELeap15: python311-base python3-PyYAML: CentOSStream8: python38-PyYAML
@@ -17,7 +17,7 @@ mappings: python3-devel: CentOSStream8: python38-devel - OpenSUSELeap15: python39-devel + OpenSUSELeap15: python311-devel python3-docutils: CentOSStream8:
@@ -37,7 +37,7 @@ mappings: python3-pip: CentOSStream8: python38-pip - OpenSUSELeap15: python39-pip + OpenSUSELeap15: python311-pip python3-pillow: CentOSStream8:
@@ -49,7 +49,7 @@ mappings: python3-setuptools: CentOSStream8: python38-setuptools - OpenSUSELeap15: python39-setuptools + OpenSUSELeap15: python311-setuptools python3-sphinx: CentOSStream8:
@@ -61,11 +61,11 @@ mappings: python3-venv: CentOSStream8: python38 - OpenSUSELeap15: python39-base + OpenSUSELeap15: python311-base python3-wheel: CentOSStream8: python38-wheel - OpenSUSELeap15: python39-pip + OpenSUSELeap15: python311-pip pypi_mappings: # Request more recent version
tests/lcitool/projects/qemu.yml +1 -1
@@ -85,7 +85,7 @@ packages: - pam - pcre-static - pixman - - pipewire + - libpipewire-dev - pkg-config - pulseaudio - python3
tests/lcitool/targets/opensuse-leap-15.yml +2 -2
@@ -1,3 +1,3 @@ paths: - pip3: /usr/bin/pip3.9 - python: /usr/bin/python3.9 + pip3: /usr/bin/pip3.11 + python: /usr/bin/python3.11
Signature · 1 line
2.41.0
PATCH 5/9 configure: never use PyPI for Meson
In reply to Paolo BonziniSince there is a vendored copy, there is no point in choosing online operation.
--- configure | 6 ------ 1 file changed, 6 deletions(-)
configure +0 -6
@@ -1018,13 +1018,7 @@ fi python="$python -B" mkvenv="$python ${source_path}/python/scripts/mkvenv.py" -mkvenv_flags="" -if test "$download" = "enabled" ; then - mkvenv_flags="--online" -fi - if ! $mkvenv ensure \ - $mkvenv_flags \ --dir "${source_path}/python/wheels" \ --diagnose "meson" \ "meson>=0.63.0" ;
Signature · 1 line
2.41.0
PATCH 6/9 python: use vendored tomli
In reply to Paolo BonziniDebian only introduced tomli in the bookworm release. Use a vendored wheel to avoid requiring a package that is only in bullseye-backports and is also absent in Ubuntu 20.04.
While at it, fix an issue in the vendor.py scripts which does not add a newline after each package and hash.
--- configure | 6 ++++++ python/scripts/vendor.py | 5 ++++- python/wheels/tomli-2.0.1-py3-none-any.whl | Bin 0 -> 12757 bytes 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 python/wheels/tomli-2.0.1-py3-none-any.whl
configure +6 -0
@@ -1018,6 +1018,12 @@ fi python="$python -B" mkvenv="$python ${source_path}/python/scripts/mkvenv.py" +# Finish preparing the virtual environment using vendored .whl files + +if $python -c 'import sys; sys.exit(sys.version_info >= (3,11))'; then + $mkvenv ensure --dir "${source_path}/python/wheels" \ + 'tomli>=1.2.0' || exit 1 +fi if ! $mkvenv ensure \ --dir "${source_path}/python/wheels" \ --diagnose "meson" \
python/scripts/vendor.py +4 -1
@@ -43,13 +43,16 @@ def main() -> int: packages = { "meson==0.63.3": "d677b809c4895dcbaac9bf6c43703fcb3609a4b24c6057c78f828590049cf43a", + + "tomli==2.0.1": + "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", } vendor_dir = Path(__file__, "..", "..", "wheels").resolve() with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file: for dep_spec, checksum in packages.items(): - file.write(f"{dep_spec} --hash=sha256:{checksum}") + print(f"{dep_spec} --hash=sha256:{checksum}", file=file) file.flush() cli_args = [
python/wheels/tomli-2.0.1-py3-none-any.whl new file binary +0 -0
Signature · 1 line
2.41.0
PATCH 7/9 configure: switch to ensuregroup
In reply to Paolo BonziniUsing the new ensuregroup command, the desired versions of meson and sphinx can be placed in pythondeps.toml rather than configure.
The meson.install entry in pythondeps.toml matches the version that is found in python/wheels. This ensures that mkvenv.py uses the bundled wheel even if PyPI is enabled; thus not introducing warnings or errors from versions that are more recent than the one used in CI.
The sphinx entries match what is shipped in Fedora 38. It's the last release that has support for older versions of Python (sphinx 6.0 requires Python 3.8) and especially docutils (of which sphinx 6.0 requires version 0.18). This is important because Ubuntu 20.04 has docutils 0.14 and Debian 11 has docutils 0.16.
"mkvenv.py ensure" is only used to bootstrap tomli.
--- configure | 14 ++++---------- pythondeps.toml | 8 ++++++++ 2 files changed, 12 insertions(+), 10 deletions(-)
configure +4 -10
@@ -1024,13 +1024,8 @@ if $python -c 'import sys; sys.exit(sys.version_info >= (3,11))'; then $mkvenv ensure --dir "${source_path}/python/wheels" \ 'tomli>=1.2.0' || exit 1 fi -if ! $mkvenv ensure \ - --dir "${source_path}/python/wheels" \ - --diagnose "meson" \ - "meson>=0.63.0" ; -then - exit 1 -fi +$mkvenv ensuregroup --dir "${source_path}/python/wheels" \ + "${source_path}/pythondeps.toml" meson || exit 1 # At this point, we expect Meson to be installed and available. # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
@@ -1047,10 +1042,9 @@ if test "$download" = "enabled" -a "$docs" = "enabled" ; then fi if test "$docs" != "disabled" ; then - if ! $mkvenv ensure \ + if ! $mkvenv ensuregroup \ $mkvenv_flags \ - --diagnose "sphinx-build" \ - "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0"; + "${source_path}/pythondeps.toml" docs; then if test "$docs" = "enabled" ; then exit 1
pythondeps.toml +8 -0
@@ -15,3 +15,11 @@ # precise error diagnostics to the user. For example, # 'sphinx-build' can be used as a bellwether for the # presence of 'sphinx' in the system. + +[meson] +# The install key should match the version in python/wheels/ +meson = { accepted = ">=0.63.0", installed = "0.63.3", canary = "meson" } + +[docs] +sphinx = { accepted = ">=1.6", installed = "5.3.0", canary = "sphinx-build" } +sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.1.1" }
Signature · 1 line
2.41.0
PATCH 8/9 Revert "tests: Use separate virtual environment for avocado"
In reply to Paolo BonziniThis reverts commit e8e4298feadae7924cf7600bb3bcc5b0a8d7cbe9.
ensuregroup allows to specify both the acceptable versions of avocado, and a locked version to be used when avocado is not installed as a system pacakge. This lets us install avocado in pyvenv/ using "mkvenv.py" and reuse the distro package on Fedora and CentOS Stream (the only distros where it's available).
ensuregroup's usage of "(>=..., <=...)" constraints when evaluating the distro package, and "==" constraints when installing it from PyPI, makes it possible to avoid conflicts between the known-good version and a package plugins included in the distro.
This is because package plugins have "==" constraints on the version that is included in the distro, and, using "pip install avocado==88.1" on a venv that includes system packages will result in an error:
avocado-framework-plugin-varianter-yaml-to-mux 98.0 requires avocado-framework==98.0, but you have avocado-framework 88.1 which is incompatible. avocado-framework-plugin-result-html 98.0 requires avocado-framework==98.0, but you have avocado-framework 88.1 which is incompatible.
But at the same time, if the venv does not include a system distribution of avocado then we can install a known-good version and stick to LTS releases.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1663
--- .gitlab-ci.d/buildtest.yml | 6 +++--- docs/devel/acpi-bits.rst | 6 +++--- docs/devel/testing.rst | 14 +++++++------- python/scripts/mkvenv.py | 13 +++++-------- pythondeps.toml | 7 +++++++ .../org.centos/stream/8/x86_64/test-avocado | 4 ++-- scripts/device-crash-test | 2 +- tests/Makefile.include | 19 ++++++++----------- tests/requirements.txt | 6 ------ tests/vm/Makefile.include | 2 +- 10 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 tests/requirements.txt
.gitlab-ci.d/buildtest.yml +3 -3
@@ -103,7 +103,7 @@ crash-test-debian: script: - cd build - make NINJA=":" check-venv - - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386 + - pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386 build-system-fedora: extends:
@@ -146,8 +146,8 @@ crash-test-fedora: script: - cd build - make NINJA=":" check-venv - - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc - - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32 + - pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc + - pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32 build-system-centos: extends:
docs/devel/acpi-bits.rst +3 -3
@@ -61,19 +61,19 @@ Under ``tests/avocado/`` as the root we have: :: $ make check-venv (needed only the first time to create the venv) - $ ./tests/venv/bin/avocado run -t acpi tests/avocado + $ ./pyvenv/bin/avocado run -t acpi tests/avocado The above will run all acpi avocado tests including this one. In order to run the individual tests, perform the following: :: - $ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py --tap - + $ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py --tap - The above will produce output in tap format. You can omit "--tap -" in the end and it will produce output like the following: :: - $ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py + $ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py Fetching asset from tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits JOB ID : eab225724da7b64c012c65705dc2fa14ab1defef JOB LOG : /home/anisinha/avocado/job-results/job-2022-10-10T17.58-eab2257/job.log
docs/devel/testing.rst +7 -7
@@ -894,9 +894,9 @@ You can run the avocado tests simply by executing: make check-avocado -This involves the automatic creation of Python virtual environment -within the build tree (at ``tests/venv``) which will have all the -right dependencies, and will save tests results also within the +This involves the automatic installation, from PyPI, of all the +necessary avocado-framework dependencies into the QEMU venv within the +build tree (at ``./pyvenv``). Test results are also saved within the build tree (at ``tests/results``). Note: the build environment must be using a Python 3 stack, and have
@@ -953,7 +953,7 @@ may be invoked by running: .. code:: - tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/ + pyvenv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/ Note that if ``make check-avocado`` was not executed before, it is possible to create the Python virtual environment with the dependencies
@@ -968,20 +968,20 @@ a test file. To run tests from a single file within the build tree, use: .. code:: - tests/venv/bin/avocado run tests/avocado/$TESTFILE + pyvenv/bin/avocado run tests/avocado/$TESTFILE To run a single test within a test file, use: .. code:: - tests/venv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME + pyvenv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME Valid test names are visible in the output from any previous execution of Avocado or ``make check-avocado``, and can also be queried using: .. code:: - tests/venv/bin/avocado list tests/avocado + pyvenv/bin/avocado list tests/avocado Manual Installation ~~~~~~~~~~~~~~~~~~~
python/scripts/mkvenv.py +5 -8
@@ -964,14 +964,11 @@ def _parse_groups(file: str) -> Dict[str, Dict[str, Any]]: "Python >=3.11 does not have tomllib... what have you done!?" ) - try: - # Use loads() to support both tomli v1.2.x (Ubuntu 22.04, - # Debian bullseye-backports) and v2.0.x - with open(file, "r", encoding="ascii") as depfile: - contents = depfile.read() - return tomllib.loads(contents) # type: ignore - except tomllib.TOMLDecodeError as exc: - raise Ouch(f"parsing {file} failed: {exc}") from exc + # Use loads() to support both tomli v1.2.x (Ubuntu 22.04, + # Debian bullseye-backports) and v2.0.x + with open(file, "r", encoding="ascii") as depfile: + contents = depfile.read() + return tomllib.loads(contents) # type: ignore def ensure_group(
pythondeps.toml +7 -0
@@ -23,3 +23,10 @@ meson = { accepted = ">=0.63.0", installed = "0.63.3", canary = "meson" } [docs] sphinx = { accepted = ">=1.6", installed = "5.3.0", canary = "sphinx-build" } sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.1.1" } + +[avocado] +# Note that qemu.git/python/ is always implicitly installed. +# Prefer an LTS version when updating the accepted versions of +# avocado-framework, for example right now the limit is 92.x. +avocado-framework = { accepted = "(>=88.1, <93.0)", installed = "88.1", canary = "avocado" } +pycdlib = { accepted = ">=1.11.0" }
scripts/ci/org.centos/stream/8/x86_64/test-avocado +2 -2
@@ -4,7 +4,7 @@ # KVM and x86_64, or tests that are generic enough to be valid for all # targets. Such a test list can be generated with: # -# ./tests/venv/bin/avocado list --filter-by-tags-include-empty \ +# ./pyvenv/bin/avocado list --filter-by-tags-include-empty \ # --filter-by-tags-include-empty-key -t accel:kvm,arch:x86_64 \ # tests/avocado/ #
@@ -22,7 +22,7 @@ # - tests/avocado/virtio_check_params.py:VirtioMaxSegSettingsCheck.test_machine_types # make get-vm-images -./tests/venv/bin/avocado run \ +./pyvenv/bin/avocado run \ --job-results-dir=tests/results/ \ tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_i440fx_kvm \ tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_q35_kvm \
scripts/device-crash-test +1 -1
@@ -43,7 +43,7 @@ except ModuleNotFoundError as exc: print(f"Module '{exc.name}' not found.") print(" Try 'make check-venv' from your build directory,") print(" and then one way to run this script is like so:") - print(f' > $builddir/tests/venv/bin/python3 "{path}"') + print(f' > $builddir/pyvenv/bin/python3 "{path}"') sys.exit(1) logger = logging.getLogger('device-crash-test')
tests/Makefile.include +8 -11
@@ -89,10 +89,8 @@ distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES) # Build up our target list from the filtered list of ninja targets TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets))) -TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv -TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt +TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results -TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3 ifndef AVOCADO_TESTS AVOCADO_TESTS=tests/avocado endif
@@ -108,20 +106,19 @@ else endif quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \ - $(TESTS_PYTHON) -m pip -q --disable-pip-version-check $1, \ + $(PYTHON) -m pip -q --disable-pip-version-check $1, \ "VENVPIP","$1") -$(TESTS_VENV_DIR): $(TESTS_VENV_REQ) - $(call quiet-command, $(PYTHON) -m venv $@, VENV, $@) +$(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml $(call quiet-venv-pip,install -e "$(SRC_PATH)/python/") - $(call quiet-venv-pip,install -r $(TESTS_VENV_REQ)) + $(PYTHON) python/scripts/mkvenv.py ensuregroup --online $< avocado $(call quiet-command, touch $@) $(TESTS_RESULTS_DIR): $(call quiet-command, mkdir -p $@, \ MKDIR, $@) -check-venv: $(TESTS_VENV_DIR) +check-venv: $(TESTS_VENV_TOKEN) FEDORA_31_ARCHES_TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGETS))) FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(FEDORA_31_ARCHES_TARGETS))
@@ -131,7 +128,7 @@ FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES)) # download one specific Fedora 31 image get-vm-image-fedora-31-%: check-venv $(call quiet-command, \ - $(TESTS_PYTHON) -m avocado vmimage get \ + $(PYTHON) -m avocado vmimage get \ --distro=fedora --distro-version=31 --arch=$*, \ "AVOCADO", "Downloading avocado tests VM image for $*")
@@ -140,7 +137,7 @@ get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOW check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images $(call quiet-command, \ - $(TESTS_PYTHON) -m avocado \ + $(PYTHON) -m avocado \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \ --filter-by-tags-include-empty-key) \
@@ -163,7 +160,7 @@ check: check-build: run-ninja check-clean: - rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR) + rm -rf $(TESTS_RESULTS_DIR) clean: check-clean clean-tcg distclean: distclean-tcg
tests/requirements.txt deleted +0 -6
@@ -1,6 +0,0 @@ -# Add Python module requirements, one per line, to be installed -# in the tests/venv Python virtual environment. For more info, -# refer to: https://pip.pypa.io/en/stable/user_guide/#id1 -# Note that qemu.git/python/ is always implicitly installed. -avocado-framework==88.1 -pycdlib==1.11.0
tests/vm/Makefile.include +1 -1
@@ -5,7 +5,7 @@ ifeq ($(realpath $(SRC_PATH)),$(realpath .)) VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 VM_VENV = else -VM_PYTHON = $(TESTS_PYTHON) +VM_PYTHON = $(PYTHON) VM_VENV = check-venv endif
Signature · 1 line
2.41.0
PATCH 9/9 tests/docker: add python3-tomli dependency to containers
In reply to Paolo BonziniInstead of having CI pick tomli from the vendored wheel at configure time, place it in the containers.
--- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- tests/docker/dockerfiles/centos8.docker | 3 ++- .../dockerfiles/debian-all-test-cross.docker | 7 ++++++- .../docker/dockerfiles/debian-amd64-cross.docker | 4 ++++ tests/docker/dockerfiles/debian-amd64.docker | 4 ++++ .../docker/dockerfiles/debian-arm64-cross.docker | 4 ++++ .../docker/dockerfiles/debian-armel-cross.docker | 4 ++++ .../docker/dockerfiles/debian-armhf-cross.docker | 4 ++++ .../dockerfiles/debian-hexagon-cross.docker | 6 +++++- .../dockerfiles/debian-mips64el-cross.docker | 4 ++++ .../docker/dockerfiles/debian-mipsel-cross.docker | 4 ++++ .../dockerfiles/debian-ppc64el-cross.docker | 4 ++++ .../docker/dockerfiles/debian-s390x-cross.docker | 4 ++++ .../dockerfiles/debian-tricore-cross.docker | 2 ++ tests/docker/dockerfiles/fedora-i386-cross.docker | 1 + tests/docker/dockerfiles/opensuse-leap.docker | 3 ++- tests/docker/dockerfiles/ubuntu2004.docker | 4 +++- tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/mappings.yml | 15 +++++++++++++++ tests/lcitool/projects/qemu.yml | 1 + tests/vm/generated/freebsd.json | 1 + 22 files changed, 77 insertions(+), 7 deletions(-)
.gitlab-ci.d/cirrus/freebsd-13.vars +1 -1
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake' NINJA='/usr/local/bin/ninja' PACKAGING_COMMAND='pkg' PIP3='/usr/local/bin/pip-3.8' -PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 xorriso zstd' +PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-tomli py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 xorriso zstd' PYPI_PKGS='' PYTHON='/usr/local/bin/python3'
.gitlab-ci.d/cirrus/macos-12.vars +1 -1
@@ -12,5 +12,5 @@ NINJA='/opt/homebrew/bin/ninja' PACKAGING_COMMAND='brew' PIP3='/opt/homebrew/bin/pip3' PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol tesseract usbredir vde vte3 xorriso zlib zstd' -PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme' +PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli' PYTHON='/opt/homebrew/bin/python3'
tests/docker/dockerfiles/centos8.docker +2 -1
@@ -133,7 +133,8 @@ RUN /usr/bin/pip3.8 install \ meson==0.63.2 \ pillow \ sphinx \ - sphinx-rtd-theme + sphinx-rtd-theme \ + tomli ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8"
tests/docker/dockerfiles/debian-all-test-cross.docker +6 -1
@@ -58,7 +58,12 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ libc6-dev-sh4-cross \ gcc-sparc64-linux-gnu \ libc6-dev-sparc64-cross \ - python3-venv + python3-pip \ + python3-setuptools \ + python3-venv \ + python3-wheel + +RUN /usr/bin/pip3 install tomli ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs --disable-tools ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
tests/docker/dockerfiles/debian-amd64-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-amd64.docker +4 -0
@@ -115,9 +115,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -143,6 +145,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-arm64-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-armel-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-armhf-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-hexagon-cross.docker +5 -1
@@ -21,11 +21,15 @@ RUN apt-get update && \ flex \ git \ ninja-build \ - python3-venv && \ + python3-pip \ + python3-setuptools \ + python3-venv \ + python3-wheel && \ # Install QEMU build deps for use in CI DEBIAN_FRONTEND=noninteractive eatmydata \ apt build-dep -yy --arch-only qemu +RUN /usr/bin/pip3 install tomli ENV TOOLCHAIN_INSTALL /opt ENV TOOLCHAIN_RELEASE 16.0.0
tests/docker/dockerfiles/debian-mips64el-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-mipsel-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-ppc64el-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-s390x-cross.docker +4 -0
@@ -47,9 +47,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ + python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ + python3-wheel \ python3-yaml \ rpm2cpio \ sed \
@@ -65,6 +67,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ dpkg-reconfigure locales +RUN /usr/bin/pip3 install tomli + ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make"
tests/docker/dockerfiles/debian-tricore-cross.docker +2 -0
@@ -36,6 +36,8 @@ RUN apt update && \ python3-wheel \ python3-venv +RUN /usr/bin/pip3 install tomli + RUN curl -#SL https://github.com/bkoppelmann/package_940/releases/download/tricore-toolchain-9.40/tricore-toolchain-9.4.0.tar.gz \ | tar -xzC /usr/local/
tests/docker/dockerfiles/fedora-i386-cross.docker +1 -0
@@ -24,6 +24,7 @@ ENV PACKAGES \ nettle-devel.i686 \ pcre-devel.i686 \ pixman-devel.i686 \ + python3-tomli \ sysprof-capture-devel.i686 \ zlib-devel.i686
tests/docker/dockerfiles/opensuse-leap.docker +2 -1
@@ -130,7 +130,8 @@ RUN /usr/bin/pip3.11 install \ meson==0.63.2 \ pillow \ sphinx \ - sphinx-rtd-theme + sphinx-rtd-theme \ + tomli ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8"
tests/docker/dockerfiles/ubuntu2004.docker +3 -1
@@ -141,7 +141,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc -RUN /usr/bin/pip3 install meson==0.63.2 +RUN /usr/bin/pip3 install \ + meson==0.63.2 \ + tomli ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8"
tests/docker/dockerfiles/ubuntu2204.docker +1 -0
@@ -117,6 +117,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-pip \ python3-sphinx \ python3-sphinx-rtd-theme \ + python3-tomli \ python3-venv \ python3-yaml \ rpm2cpio \
tests/lcitool/mappings.yml +15 -0
@@ -59,6 +59,15 @@ mappings: CentOSStream8: OpenSUSELeap15: + python3-tomli: + # test using tomllib + apk: + Fedora: + Debian12: + # Not available for Python 3.8/3.9 + CentOSStream8: + OpenSUSELeap15: + python3-venv: CentOSStream8: python38 OpenSUSELeap15: python311-base
@@ -75,3 +84,9 @@ pypi_mappings: # Drop packages that need devel headers python3-numpy: OpenSUSELeap15: + + # see above + python3-tomli: + apk: + Fedora: + Debian12:
tests/lcitool/projects/qemu.yml +1 -0
@@ -96,6 +96,7 @@ packages: - python3-pip - python3-sphinx - python3-sphinx-rtd-theme + - python3-tomli - python3-venv - rpm2cpio - sdl2
tests/vm/generated/freebsd.json +1 -0
@@ -56,6 +56,7 @@ "py39-pip", "py39-sphinx", "py39-sphinx_rtd_theme", + "py39-tomli", "py39-yaml", "python3", "rpm2cpio",
Signature · 1 line
2.41.0
Quoted 31 lines · Paolo Bonzini
This series introduce a new installation command for
mkvenv.pythat retrieves the packages to be installed from a TOML file. This allows being more flexible in using the system version of a package, while at the same time using a known-good version when installing the package. This is important for packages that sometimes have backwards-incompatible changes or that depend on specific versions of their dependencies.For example, in the case of sphinx we can always use the last version that supports older versions of Python and especially docutils (Ubuntu 20.04 for example would not support sphinx 6.0), and in the case of Avocado we can avoid installing a package that conflicts with any plugins already existing in the system package path. This in turn enables using the same virtual environment for both the build and qemu-iotests. John has patches for this.
For the configuration file, TOML was chosen because it was more human readable and easier to edit than JSON. A parser is available in the Python 3.11 standard library; for older versions, the API-compatible replacement tomli is very small (12k). I am introducing it as a vendored .whl file because it is not installed by default in most distros (unlike pip and setuptools which were introduced in 8.0) and because Debian 11 only has it in bullseye-backports. However, if preferred the patch "python: use vendored tomli" can be dropped. In that case, tomli will have to be installed from either PyPI or bullseye-backports.
While tomli is bundled with pip, this is only true of recent versions of pip. Of all the supported OSes pretty much only FreeBSD has a recent enough version of pip while staying on Python <3.11. So we cannot use the same trick that is in place for distlib.
Quoted 4 lines
In order to pick the tomli mapping, lcitool is updated to a recent version. As a side effect this updates from LEAP 15.4 to 15.5.
Paolo
I'm still nose to the grindstone trying to finish up the asyncio machine demo, but I made good progress today and I'll try to get a good look at this ASAP.
(But, I suppose we're both about to pop out for PTO soon, so...)
Quoted 62 lines
Paolo Bonzini (9):
python: mkvenv: tweak the matching of --diagnose to depspecs
python: mkvenv: introduce TOML-like representation of dependencies
python: mkvenv: add ensuregroup command
lcitool: bump libvirt-ci submodule and regenerate
configure: never use PyPI for Meson
python: use vendored tomli
configure: switch to ensuregroup
Revert "tests: Use separate virtual environment for avocado" tests/docker: add python3-tomli dependency to containers.gitlab-ci.d/buildtest.yml | 6 +- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- configure | 22 +- docs/devel/acpi-bits.rst | 6 +- docs/devel/testing.rst | 14 +- python/scripts/mkvenv.py | 201 ++++++++++++++++-- python/scripts/vendor.py | 5 +- python/setup.cfg | 9 + python/wheels/tomli-2.0.1-py3-none-any.whl | Bin 0 -> 12757 bytes pythondeps.toml | 32 +++ .../org.centos/stream/8/x86_64/test-avocado | 4 +- scripts/device-crash-test | 2 +- tests/Makefile.include | 19 +- tests/docker/dockerfiles/centos8.docker | 3 +- .../dockerfiles/debian-all-test-cross.docker | 7 +- .../dockerfiles/debian-amd64-cross.docker | 6 +- tests/docker/dockerfiles/debian-amd64.docker | 4 + .../dockerfiles/debian-arm64-cross.docker | 6 +- .../dockerfiles/debian-armel-cross.docker | 6 +- .../dockerfiles/debian-armhf-cross.docker | 6 +- .../dockerfiles/debian-hexagon-cross.docker | 6 +- .../dockerfiles/debian-mips64el-cross.docker | 6 +- .../dockerfiles/debian-mipsel-cross.docker | 6 +- .../dockerfiles/debian-ppc64el-cross.docker | 6 +- .../dockerfiles/debian-riscv64-cross.docker | 2 +- .../dockerfiles/debian-s390x-cross.docker | 6 +- .../dockerfiles/debian-tricore-cross.docker | 2 + .../dockerfiles/fedora-i386-cross.docker | 1 + .../dockerfiles/fedora-win32-cross.docker | 2 +- .../dockerfiles/fedora-win64-cross.docker | 2 +- tests/docker/dockerfiles/opensuse-leap.docker | 23 +- tests/docker/dockerfiles/ubuntu2004.docker | 4 +- tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/libvirt-ci | 2 +- tests/lcitool/mappings.yml | 27 ++- tests/lcitool/projects/qemu.yml | 3 +- tests/lcitool/targets/opensuse-leap-15.yml | 4 +- tests/requirements.txt | 6 - tests/vm/Makefile.include | 2 +- tests/vm/generated/freebsd.json | 1 + 41 files changed, 371 insertions(+), 103 deletions(-) create mode 100644 python/wheels/tomli-2.0.1-py3-none-any.whl create mode 100644 pythondeps.toml delete mode 100644 tests/requirements.txt--
2.41.0
Hi Paolo,
Quoted 25 lines · Paolo Bonzini
This series introduce a new installation command for
mkvenv.pythat retrieves the packages to be installed from a TOML file. This allows being more flexible in using the system version of a package, while at the same time using a known-good version when installing the package. This is important for packages that sometimes have backwards-incompatible changes or that depend on specific versions of their dependencies.For example, in the case of sphinx we can always use the last version that supports older versions of Python and especially docutils (Ubuntu 20.04 for example would not support sphinx 6.0), and in the case of Avocado we can avoid installing a package that conflicts with any plugins already existing in the system package path. This in turn enables using the same virtual environment for both the build and qemu-iotests. John has patches for this.
For the configuration file, TOML was chosen because it was more human readable and easier to edit than JSON. A parser is available in the Python 3.11 standard library; for older versions, the API-compatible replacement tomli is very small (12k). I am introducing it as a vendored .whl file because it is not installed by default in most distros (unlike pip and setuptools which were introduced in 8.0) and because Debian 11 only has it in bullseye-backports. However, if preferred the patch "python: use vendored tomli" can be dropped. In that case, tomli will have to be installed from either PyPI or bullseye-backports.
Quoted 7 lines
While tomli is bundled with pip, this is only true of recent versions of pip. Of all the supported OSes pretty much only FreeBSD has a recent enough version of pip while staying on Python <3.11. So we cannot use the same trick that is in place for distlib.
In order to pick the tomli mapping, lcitool is updated to a recent version. As a side effect this updates from LEAP 15.4 to 15.5.
Does this fix the second point of commit eaf245becd ("Revert "tests/requirements.txt: bump up avocado-framework version to 101.0"")
Quoted 3 lines
Second, the recent changes to Python handling mean that there is a single virtual environment for all the build, instead of a separate one for testing.
?
If so, what's left to be able to run QEMU (Avocado) test suite on macOS is the first point from the same commit:
Quoted 2 lines
Avocado is not logging of command lines or terminal output, and not collecting Python logs outside the avocado namespace.
This seems to be fixed in Avocado 102.0:
https://avocado-framework.readthedocs.io/en/102.0/releases/102_0.html
Quoted 2 lines
The root logger handler was restored. This enables all loggers out of avocado.* namespace by default.
Assuming this is enough for macOS, what would be the next change, moving to 102.0 or integrate 102.0 in the current set? I.e.:
avocado-framework = { accepted = "(>=88.1, <93.0, 102.0)", ... }
? But I expect the "<93.0" filter to clash...
Thanks,
Phil.
Quoted 6 lines · Philippe Mathieu-Daudé
Does this fix the second point of commit
eaf245becd("Revert "tests/requirements.txt: bump up avocado-framework version to 101.0"")Quoted 3 lines
Second, the recent changes to Python handling mean that there is a single virtual environment for all the build, instead of a separate one for testing.
This was reverted and Avocado has a separate venv than pyvenv/ (which is the one created by configure). This series makes it possible to have again a single virtual environment for all the build.
Quoted 4 lines
Quoted 2 lines
Avocado is not logging of command lines or terminal output, and not collecting Python logs outside the avocado namespace.
This seems to be fixed in Avocado 102.0:
Correct.
Quoted 4 lines
Assuming this is enough for macOS, what would be the next change, moving to 102.0 or integrate 102.0 in the current set? I.e.:
avocado-framework = { accepted = "(>=88.1, <93.0, 102.0)", ... }
The plan is to:
1) wait for the next LTS release of Avocado (103.0)
2) wait for it to be packaged in Fedora
3) change "accepted" to be "~= 103.0"
Users of Fedora will have to switch from the 92.0 module to the 103.0 module if they want to use the system avocado.
Paolo