aboutsummaryrefslogtreecommitdiff
path: root/docs/devel
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-11-27 08:58:21 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2023-11-27 08:58:21 -0500
commit839e9a48df382359fc18579765907f1bc1f833c3 (patch)
tree9d1ce2056611e512e158e19869b978c2629b14cf /docs/devel
parent4705fc0c8511d073bee4751c3c974aab2b10a970 (diff)
parent81a541e9f0838753d06d61b026688bea1eba7c0b (diff)
downloadqemu-839e9a48df382359fc18579765907f1bc1f833c3.zip
qemu-839e9a48df382359fc18579765907f1bc1f833c3.tar.gz
qemu-839e9a48df382359fc18579765907f1bc1f833c3.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* document what configure does with virtual environments * bump known good meson version to v1.2.3 * upgrade macOS to 13 (Ventura) and Add manual testing of macOS 14 (Sonoma) * use simple assertions instead of Coverity models * miscellaneous fixes * adjust URL to Coverity tools # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmVgv78UHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroPTmgf/VgDEIRP0teMsz1qAPWyH3eanoF8w # XN9gN0jYUqv1pYVdBws3qxsZFr0GCUrEhF46wbDBj5BgNYjiO6Cg7la1Ryyry7sV # GmwgAQhaCelY7USS4tGeK2A/EpEx4M/pOKfzJhAyjm9d87bdOBoankeYjCR0XZqD # O9CypjA9mxx6Gi28RC1OjIIPxERgazpDMmm1gntEI29qoYiKvD7uOjA3EP7zrBhz # 6Qi1/cx5WgvhePnFAab25jQDgkFaPViZSV28UdfH/29+bUkcJhyki56+vIoLbEtK # 18+wVQkOFl10Ibo7cmQ4JnT8q7BaqhXbO54xmT3LKzMi1I8RCOpOiFFGjg== # =+YGq # -----END PGP SIGNATURE----- # gpg: Signature made Fri 24 Nov 2023 10:22:39 EST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: scripts: adjust url to Coverity tools configure: Make only once with pseudo-"in source tree" builds system: Use &error_abort in memory_region_init_ram_[device_]ptr() disas/cris: Pass buffer size to format_dec() to avoid overflow warning audio: Free consumed default audio devices .gitlab-ci.d/cirrus: Add manual testing of macOS 14 (Sonoma) buildsys: Bump known good meson version to v1.2.3 docs: document what configure does with virtual environments tests: respect --enable/--disable-download for Avocado coverity: physmem: use simple assertions instead of modelling Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'docs/devel')
-rw-r--r--docs/devel/build-system.rst88
1 files changed, 85 insertions, 3 deletions
diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst
index 21f78da..43d6005 100644
--- a/docs/devel/build-system.rst
+++ b/docs/devel/build-system.rst
@@ -122,10 +122,78 @@ functioning. These are performed using a few more helper functions:
indicated by $TMPC.
-Python virtual environments and the QEMU build system
------------------------------------------------------
+Python virtual environments and the build process
+-------------------------------------------------
+
+An important step in ``configure`` is to create a Python virtual
+environment (venv) during the configuration phase. The Python interpreter
+comes from the ``--python`` command line option, the ``$PYTHON`` variable
+from the environment, or the system PATH, in this order. The venv resides
+in the ``pyvenv`` directory in the build tree, and provides consistency
+in how the build process runs Python code.
+
+At this stage, ``configure`` also queries the chosen Python interpreter
+about QEMU's build dependencies. Note that the build process does *not*
+look for ``meson``, ``sphinx-build`` or ``avocado`` binaries in the PATH;
+likewise, there are no options such as ``--meson`` or ``--sphinx-build``.
+This avoids a potential mismatch, where Meson and Sphinx binaries on the
+PATH might operate in a different Python environment than the one chosen
+by the user during the build process. On the other hand, it introduces
+a potential source of confusion where the user installs a dependency but
+``configure`` is not able to find it. When this happens, the dependency
+was installed in the ``site-packages`` directory of another interpreter,
+or with the wrong ``pip`` program.
+
+If a package is available for the chosen interpreter, ``configure``
+prepares a small script that invokes it from the venv itself[#distlib]_.
+If not, ``configure`` can also optionally install dependencies in the
+virtual environment with ``pip``, either from wheels in ``python/wheels``
+or by downloading the package with PyPI. Downloading can be disabled with
+``--disable-download``; and anyway, it only happens when a ``configure``
+option (currently, only ``--enable-docs``) is explicitly enabled but
+the dependencies are not present[#pip]_.
+
+.. [#distlib] The scripts are created based on the package's metadata,
+ specifically the ``console_script`` entry points. This is the
+ same mechanism that ``pip`` uses when installing a package.
+ Currently, in all cases it would be possible to use ``python -m``
+ instead of an entry point script, which makes this approach a
+ bit overkill. On the other hand, creating the scripts is
+ future proof and it makes the contents of the ``pyvenv/bin``
+ directory more informative. Portability is also not an issue,
+ because the Python Packaging Authority provides a package
+ ``distlib.scripts`` to perform this task.
+
+.. [#pip] ``pip`` might also be used when running ``make check-avocado``
+ if downloading is enabled, to ensure that Avocado is
+ available.
+
+The required versions of the packages are stored in a configuration file
+``pythondeps.toml``. The format is custom to QEMU, but it is documented
+at the top of the file itself and it should be easy to understand. The
+requirements should make it possible to use the version that is packaged
+that is provided by supported distros.
+
+When dependencies are downloaded, instead, ``configure`` uses a "known
+good" version that is also listed in ``pythondeps.toml``. In this
+scenario, ``pythondeps.toml`` behaves like the "lock file" used by
+``cargo``, ``poetry`` or other dependency management systems.
+
+
+Bundled Python packages
+-----------------------
+
+Python packages that are **mandatory** dependencies to build QEMU,
+but are not available in all supported distros, are bundled with the
+QEMU sources. Currently this includes Meson (outdated in CentOS 8
+and derivatives, Ubuntu 20.04 and 22.04, and openSUSE Leap) and tomli
+(absent in Ubuntu 20.04).
+
+If you need to update these, please do so by modifying and rerunning
+``python/scripts/vendor.py``. This script embeds the sha256 hash of
+package sources and checks it. The pypi.org web site provides an easy
+way to retrieve the sha256 hash of the sources.
-TBD
Stage 2: Meson
==============
@@ -376,6 +444,15 @@ This is needed to obey the --python= option passed to the configure
script, which may point to something other than the first python3
binary on the path.
+By the time Meson runs, Python dependencies are available in the virtual
+environment and should be invoked through the scripts that ``configure``
+places under ``pyvenv``. One way to do so is as follows, using Meson's
+``find_program`` function::
+
+ sphinx_build = find_program(
+ fs.parent(python.full_path()) / 'sphinx-build',
+ required: get_option('docs'))
+
Stage 3: Make
=============
@@ -434,6 +511,11 @@ number of dynamically created files listed later.
executables. Build rules for various subdirectories are included in
other meson.build files spread throughout the QEMU source tree.
+``python/scripts/mkvenv.py``
+ A wrapper for the Python ``venv`` and ``distlib.scripts`` packages.
+ It handles creating the virtual environment, creating scripts in
+ ``pyvenv/bin``, and calling ``pip`` to install dependencies.
+
``tests/Makefile.include``
Rules for external test harnesses. These include the TCG tests
and the Avocado-based integration tests.