Skip to content

Retire the Python guard; the package is a launcher for the binary - #177

Merged
HaoZeke merged 56 commits into
developfrom
feat/retire-python-guard
Nov 26, 2026
Merged

HaoZeke merged 56 commits into
developfrom
feat/retire-python-guard

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

The static binary is the prolog and the only implementation. The Python guard, the shadow comparison and the tests that compared the two leave the repository.

  • src/eessi_arch_guard/ is a launcher: the console script and python3 -m eessi_arch_guard replace the process with the binary the wheel carries, else one on PATH, else exit 127 with a message. The exec goes through eessi_arch_guard._launch, a C extension built against the CPython limited API (3.9): multi-phase init, no module state, Py_mod_gil set to not used on a free-threaded build. Wheels per platform (x86_64, aarch64; cibuildwheel, manylinux2014): one cp39-abi3 for every GIL CPython from 3.9, and cp313t and cp314t for free-threaded CPython, which installs no abi3 wheel. Each carries the binary, share/sitepath.py, share/cvmfsrev.py, SitePackage.lua, bash and zsh completions and a man page; tools/check_wheel.py checks that set.
  • --check-mount and --check-revision move the site path check and the client revision check into the binary; sitepath.py and cvmfsrev.py keep their command lines and run them.
  • Where a test compared the Python guard with the binary, it compares the binary with one of 53 files under tests/golden/, recorded after the comparison reported 0 differences on develop. RECORD=1 rewrites them. The Python unit tests of the policy and CPU scoping become zig/policy_test.zig and zig/cpuscope_test.zig.
  • CI builds, installs and tests the wheel. COMPAT.md records what differs from the Python guard of releases before 0.4.

The recorded files keep the Python wording the binary reproduces: [Errno N] messages, exception names such as FileNotFoundError, and \udcff for bytes that are not UTF-8 in JSON.

The pinned zig-common commit (85b8e9fd, two commits before v0.13.0) state.writePrivate ignores a failed close of the cache's temporary file and renames it over the cache anyway, here and on develop; COMPAT.md says so. zig-common develop checks that close since 5d37a99; no release carries it yet.

Checked on one x86_64 host with Zig 0.17.1: zig fmt --check, zig build test; the Python suite (372 tests, extension built in place) on 3.9, 3.13t, 3.14 and 3.14t fails only the 13 or 14 tests that run sudo chown root:root, which need passwordless sudo (develop fails them on that host too; CI runs them). The cp39-abi3 wheel installs and runs on 3.9, 3.12 and 3.14, the cp313t and cp314t wheels on their interpreters with the GIL still off after importing _launch; auditwheel repair to manylinux2014 keeps the binary; abi3audit finds no ABI violation. GitHub Actions on the branch head is green in every job (run 45861034636), including the sudo tests, cibuildwheel for x86_64 and aarch64, and the installed wheels on 3.9, 3.12, 3.14, 3.13t and 3.14t. The test job runs on ubuntu-24.04: the fresh-site golden holds the one-line bash 5.2 syntax error, and bash 5.1 adds a second line.

harness.PROGRAM is TOOL_BIN or the binary in zig-out/bin; the Python guard
is no longer a target. tests/golden.py pins a program's whole output in
tests/golden/NAME.txt with @work@ and @repo@ placeholders, and RECORD=1
rewrites the files. differential.assert_golden replaces the pairwise
comparison.
…en sheets

The tests that compared the Python guard with the binary run the binary
only: explicit expectations stay as binary assertions and the full output
of each case is pinned in tests/golden. Files named for parity take
behaviour names.
The mount and module-path check of share/sitepath.py and the revision gate of
share/cvmfsrev.py are subcommands of the binary, with Zig unit tests for the
parsers and black-box tests for the command lines.
The files list every option of --help; tests/test_cli_assets.py checks that
each option appears in them.
src/eessi_arch_guard is a package whose main() locates the bundled binary,
else one on PATH, and execs it with the same arguments. The wheel carries the
binary as package data. share/sitepath.py and share/cvmfsrev.py call the
binary's --check-mount and --check-revision. towncrier moves to its own file.
…mparisons against golden sheets

Each test that compared the Python guard with the binary runs the binary
only. Explicit expectations stay as binary assertions, the cache lock test
finds its cache path from a first run, and the restore decode test compares
the binary with the committed vectors.
…ded CPython

The wheel carries the launcher and the static binary, no extension module,
so its tag is py3-none-manylinux2014_<arch>: tied to no CPython ABI, which
lets one wheel install on every CPython 3, including the free-threaded
3.13t and 3.14t that do not install abi3 wheels.

- tools/check_wheel.py fails on any other tag, on a compiled extension and
  on a missing Free Threading classifier; check_install.sh runs it.
- tests/free_threading_probe.py imports the launcher and calls locate()
  and the binary from 16 threads. test_free_threading.py runs it against
  the checkout and check_install.sh against the installed wheel: the GIL
  stays as built (off on a free-threaded build) and every call gets the
  one answer.
- check_install.sh takes the interpreter from PYTHON.
- pyproject.toml declares Free Threading :: 3 - Stable.
- CI runs check_install.sh and the launcher tests on 3.13t and 3.14t.
eessi_arch_guard._launch.execv(path, argv) wraps execv(2). main() calls it
instead of os.execv; a missing extension fails the import. The extension is
multi-phase and keeps no state; it declares Py_mod_gil as not used wherever
the headers define the slot.

Stable ABI functions checked against CPython 3.14 Misc/stable_abi.toml, all
added in 3.2 unless noted: PyArg_ParseTuple, PyUnicode_FSConverter,
PySequence_Check, PySequence_Size, PySequence_GetItem, PyBytes_AsString,
PyErr_SetFromErrnoWithFilenameObject, PyErr_SetString, PyErr_NoMemory,
PyMem_Malloc, PyMem_Free, PyType_GetFlags (behind PyUnicode_Check and PyBytes_Check),
Py_DecRef, PyModuleDef_Init (3.5). PyMem_Calloc is not
used: the 3.9 limited-API header does not declare it. Py_mod_gil is 3.13 and
Py_mod_multiple_interpreters 3.12, so both sit behind #ifdef.

GIL CPython builds with Py_LIMITED_API=0x03090000 and the wheel is tagged
cp39-abi3; free-threaded CPython builds without it (cp313t, cp314t). The
get_tag override that wrote a manylinux2014 tag by hand is gone, and
pyproject carries the cibuildwheel selection.

tools/check_wheel.py validates the new wheel set: cp39-abi3 with one
_launch.abi3.so, cp313-cp313t and cp314-cp314t with
_launch.cpython-31Xt-*.so, the bundled binary and the Free Threading
classifier; --local accepts linux_ARCH for wheels built outside manylinux.
src/eessi_arch_guard/*.so is ignored.
test_launch.py checks argument types, embedded NUL, a missing file with its
filename, a directory, leaks on the failure path, and a real exec in a child.
The free-threading probe imports _launch before it reads the GIL and calls
execv on a missing path from 16 threads.
CI and release build cp39-abi3, cp313t and cp314t wheels in the
manylinux2014 images on x86_64 and ubuntu-24.04-arm runners, with the static
binary staged into the package first. CI installs the x86_64 wheels on 3.9,
3.12, 3.14, 3.13t and 3.14t. Unit-test jobs build _launch in place first.
check_install.sh installs a given WHEEL, else builds one and checks it with
--local. tools/check_wheel.py (changed in the extension commit) checks the
abi3 and free-threaded wheel sets, accepts linux_ARCH only with --local.
README, DESIGN, RELEASING, the contributing guide and the free-threading
changelog fragment name the cp39-abi3, cp313t and cp314t wheels, the _launch
extension, and the in-place build the checkout tests need.
…epair writes

auditwheel repair --plat manylinux2014_ARCH writes a compressed platform tag
that also lists manylinux1, manylinux2010 and manylinux_2_N variants; every
component must still be a manylinux tag of the supported arches.
U+1171E AHOM CONSONANT SIGN MEDIAL RA is Mn in Unicode 13.0.0 and 15.1.0
and Mc in 16.0.0, which Python 3.14 uses, so it left the case-ignorable
class as U+1734 did in 14.0.0. A capital sigma after it lower-cases as
medial sigma on 3.14 while the guard keeps Unicode 13.0.0. The sigma test
failed on 3.14 and 3.14t with ['U+1734', 'U+1171E'] != ['U+1734'].
SIGMA_CLASS_CHANGED and COMPAT.md now list it; test_pylower_table passes
on 3.9, 3.13, 3.14 and 3.14t.
Python guard, test_unit, test_cgroup_v1, test_site_path, test_cvmfs_revision
and test_cli_help_restore_precedence stay deleted; the waitpkg alias list
from develop is in zig/guard.zig. The folded tables, shortened timeouts and
handshake-based waits from develop apply to the binary tests.
The tables keep one row per outcome class; the sections of dropped rows and
the two anchor sheets go, retained sections are unchanged, and the renamed
accelerator and path rows are new sections.
@HaoZeke
HaoZeke merged commit 3c4ec77 into develop Nov 26, 2026
26 checks passed
@HaoZeke
HaoZeke deleted the feat/retire-python-guard branch November 26, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant