On this page
  1. Where Python runs
  2. Why 3.11
  3. Standard library only
  4. The packages that are not
  5. The image's lock
    1. Updating Hypothesis, mutmut or pytest
  6. This site's Python
  7. If the test tools stop installing

Python

Every build of every game runs Python: CMake calls the generator on each configure, and rmp is a Python program. That makes Python look like the riskiest dependency the framework has. It is not, because the part every build runs uses nothing but Python's standard library. The packages that are hard to keep pinned belong to the test campaign, inside the build image, and a game never runs them.

Where Python runs#

WhatWhenNeeds
tools/configure.py, the generatorevery CMake configure, and before every Gradle and Xcode buildthe standard library; Pillow for the icons, if it is there
tools/rmp.py, behind rmpevery commandthe standard library
The gates in tools/ written in Python, and the Python inside the shell gatesrmp test, the lint jobthe standard library; PyYAML for the workflow check
The tests of the tools, tests/*_test.pyrmp testthe standard library; PyYAML for a few
The property tests, tests/*_property_test.pyrmp test property, and every nightHypothesis
Mutation testing of the Pythonrmp test mutation, every Sundaymutmut, which drives pytest
The asset makers, tools/make_example_art.py and tools/make_platformer_assets.pyby hand, when an example's art is remadePillow
CI's own scripts, .github/scripts/the canary and its reportthe standard library

Why 3.11#

The .toml is read with tomllib, which Python has had since 3.11, so that is the floor. tools/rmp.py is kept parseable by 3.8, so an older Python prints a sentence saying which version it is instead of a syntax error.

CMake does not take the first Python it finds. cmake/find_python.cmake asks each name in turn — python3, then the versioned names, then python and py — to import tomllib, and takes the first that can: on Windows python3.exe is often the Store's stub, and macOS's own python3 is older than 3.11. The versioned names stop at the newest Python that existed when the list was written; a newer one is found through python3, which is what every system installs it as. Add its versioned name to the list, and to the POSIX launcher's, which is the same, when one is released.

Standard library only#

The generator says it in its first lines: standard library only, Pillow optional. The rule is what lets a game made today configure on a Python of years from now without a package manager. The standard library modules it and rmp use are core ones — tomllib, json, re, pathlib, subprocess, argparse, hashlib, struct, shutil — and the POSIX ones, fcntl, pwd and grp, imported inside the functions that only run on Linux, as winreg is inside the ones that only run on Windows.

The packages that are not#

PackageUsed forIn the build imageOn a laptop without it
Pillowthe icons: the Windows .ico, Android's launcher icons, iOS's; the asset makersfrom apt, at the snapshot's versionno icon is made, and the build goes on. The Windows jobs install it by hash (pillow and its pillow_sha256_* keys)
PyYAMLthe workflow check, and the tests that read a workflow as YAMLfrom aptskipped, and said; inside the image a missing PyYAML fails instead
Hypothesisthe Python propertiesfrom the lockeach property module says so and is skipped; CI requires it, so a skip there is a failure
mutmut and pytestmutation testing of the Pythonfrom the lockthe mutation stage fails: it runs only in the image
clang-format, clang-tidyformatting and linting; they are Python wheels that carry the binariesfrom PyPI, by versionpip install clang-format==… clang-tidy==… at the clang_format version (Setting up)

The clang tools are pinned by version and not by hash: the image installs them with pip install and the version, and tools/versions_check.sh compares the binary on PATH with the pin. A wheel republished under the same version would not be noticed. That is the one Python install in the image without a hash.

The image's lock#

The image's test tools come from two files in the image repository: python/requirements-ci.in, the top-level pins, and python/requirements-ci.txt, the lock made from it by python/lock.py, which the image installs with --require-hashes --only-binary=:all:. The lock pins the whole graph with == and keeps, for each package, the hash of every wheel pip can pick for the image's CPython on both of its architectures — downloaded and hashed by lock.py and checked against the digest PyPI publishes.

Three things make it harder than a plain lock, and each is why a regeneration fails:

  1. Two pins belong to apt. PyYAML and Pygments are installed by apt (Pygments as a dependency of cppcheck), and pip cannot uninstall a Debian package, so the lock pins them to the exact versions the apt snapshot has. Move the snapshot and those two may move: read the new versions from the image (dpkg -s python3-yaml python3-pygments) and put them in requirements-ci.in before locking. Everything that depends on them is held back with them — that is why mutmut's interface library is not at its newest.
  2. Wheels only, for two architectures. A release that has no wheel for aarch64, or that only ships a source archive, cannot be locked. lock.py refuses it; pin the newest release that has both.
  3. It is made inside the image. The interpreter the lock is for is the image's, so lock.py runs in a build of the image, with the network, and pip-tools in a throw-away virtual environment. The command is in its docstring and in the image's README.

Updating Hypothesis, mutmut or pytest#

  1. In the image repository, change the version in python/requirements-ci.in.
  2. Regenerate the lock inside the current image:
    docker run --rm -v "$PWD":/w -w /w ghcr.io/omardev29/raylib-build:latest sh -c '
        apt-get update -qq && apt-get install -y -qq python3-venv >/dev/null &&
        python3 -m venv /tmp/v && /tmp/v/bin/pip install -q pip-tools==7.6.2 &&
        /tmp/v/bin/python python/lock.py'
  3. Read the diff of python/requirements-ci.txt: every package that moved is a change in what the tests run.
  4. Build the image (the build image), whose smoke check runs a Hypothesis property and a mutmut mutant before it publishes.
  5. In the framework, the same versions in the hypothesis, mutmut and pytest keys of thirdparty/FROZEN_VERSIONS.md, and the new digest.
  6. Run the properties and one mutation shard in the new image. A new Hypothesis can find a counterexample the old one never generated: that is a bug found, and it is fixed in the code.

This site's Python#

This site is built by one standard library script, build.py in its tools folder, with the same floor. Its property tests need Hypothesis and its browser checks a hash-pinned requirements file of their own, beside them in its tests; neither is needed to build the site.

If the test tools stop installing#

They are a test campaign, not the build. If, years from now, mutmut or Hypothesis no longer installs on any Python the image can carry, the generator, rmp, every gate that is standard library only and every game are untouched: what stops is the properties of the tools and the mutation scores of the Python. Keep the last image that has them, by its digest, for the day a change needs them, and run the rest of the ladder on a newer one. What the floors and the waivers mean is in Properties, fuzzing and mutation.