README.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. QEMU Python Tooling
  2. ===================
  3. This directory houses Python tooling used by the QEMU project to build,
  4. configure, and test QEMU. It is organized by namespace (``qemu``), and
  5. then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc).
  6. ``setup.py`` is used by ``pip`` to install this tooling to the current
  7. environment. ``setup.cfg`` provides the packaging configuration used by
  8. ``setup.py``. You will generally invoke it by doing one of the following:
  9. 1. ``pip3 install .`` will install these packages to your current
  10. environment. If you are inside a virtual environment, they will
  11. install there. If you are not, it will attempt to install to the
  12. global environment, which is **not recommended**.
  13. 2. ``pip3 install --user .`` will install these packages to your user's
  14. local python packages. If you are inside of a virtual environment,
  15. this will fail; you want the first invocation above.
  16. If you append the ``--editable`` or ``-e`` argument to either invocation
  17. above, pip will install in "editable" mode. This installs the package as
  18. a forwarder ("qemu.egg-link") that points to the source tree. In so
  19. doing, the installed package always reflects the latest version in your
  20. source tree.
  21. Installing ".[devel]" instead of "." will additionally pull in required
  22. packages for testing this package. They are not runtime requirements,
  23. and are not needed to simply use these libraries.
  24. Running ``make develop`` will pull in all testing dependencies and
  25. install QEMU in editable mode to the current environment.
  26. (It is a shortcut for ``pip3 install -e .[devel]``.)
  27. See `Installing packages using pip and virtual environments
  28. <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`_
  29. for more information.
  30. Using these packages without installing them
  31. --------------------------------------------
  32. These packages may be used without installing them first, by using one
  33. of two tricks:
  34. 1. Set your PYTHONPATH environment variable to include this source
  35. directory, e.g. ``~/src/qemu/python``. See
  36. https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH
  37. 2. Inside a Python script, use ``sys.path`` to forcibly include a search
  38. path prior to importing the ``qemu`` namespace. See
  39. https://docs.python.org/3/library/sys.html#sys.path
  40. A strong downside to both approaches is that they generally interfere
  41. with static analysis tools being able to locate and analyze the code
  42. being imported.
  43. Package installation also normally provides executable console scripts,
  44. so that tools like ``qmp-shell`` are always available via $PATH. To
  45. invoke them without installation, you can invoke e.g.:
  46. ``> PYTHONPATH=~/src/qemu/python python3 -m qemu.qmp.qmp_shell``
  47. The mappings between console script name and python module path can be
  48. found in ``setup.cfg``.
  49. Files in this directory
  50. -----------------------
  51. - ``qemu/`` Python 'qemu' namespace package source directory.
  52. - ``tests/`` Python package tests directory.
  53. - ``avocado.cfg`` Configuration for the Avocado test-runner.
  54. Used by ``make check`` et al.
  55. - ``Makefile`` provides some common testing/installation invocations.
  56. Try ``make help`` to see available targets.
  57. - ``MANIFEST.in`` is read by python setuptools, it specifies additional files
  58. that should be included by a source distribution.
  59. - ``PACKAGE.rst`` is used as the README file that is visible on PyPI.org.
  60. - ``README.rst`` you are here!
  61. - ``VERSION`` contains the PEP-440 compliant version used to describe
  62. this package; it is referenced by ``setup.cfg``.
  63. - ``setup.cfg`` houses setuptools package configuration.
  64. - ``setup.py`` is the setuptools installer used by pip; See above.