A sealed macOS bundle is user-writable, so any payload Python that runs without
a cache prefix rewrites stale bytecode inside the signed app. codesign then
reports "file modified", spctl rejects the app, and the next Squirrel.Mac
update waits on a Gatekeeper prompt. The shipped Nov 10 canary (da06acacc9),
inventoried on a real Mac, had:
- stdlib: 1,061 modules, 140 timestamp pycs (all stale: they record the
2024-01-01 source mtime, the .py files carry the build time) and 921 with
no pyc at all. bake_bytecode never compiled the interpreter's own library.
- venv site-packages: all 25,439 pycs timestamp-based and stale; pm-runtime:
all 61. uv's --compile-bytecode writes timestamp pycs, and compileall
without -f keeps a timestamp pyc whose mtime still matches, even in
unchecked-hash mode, so the bake left them as they were. Packaging then
moved the sources' mtimes.
- hermes-agent: unchecked-hash, as intended.
On that build, Desktop's ticket helper rewrote 94 stdlib pycs inside the app,
and a `python -I` import of the gateway (which ignores PYTHONPYCACHEPREFIX)
wrote 248 (103 stdlib, 145 venv).
The bake now also compiles the staged interpreter's library, found by
CPython's own landmark (os.py) beside the binary and refused when it lies
outside the payload, and forces every root (-f) so existing timestamp pycs
become unchecked-hash too. The same payload baked with this change on the Mac:
every module in all four roots unchecked-hash, nothing stale or missing, and
neither the ticket helper nor the `python -I` import wrote a file. The bake
took 25 s there; the stdlib grows by about 16 MiB. The prepared-payload
digests skip __pycache__, so they are unchanged.
Windows and Linux install trees are read-only, so their payloads never hit the
seal break. The Windows launcher reads these source-adjacent pycs (it sets no
cache prefix for a baked payload), so there the change only removes
recompiles.
ShipIt strips the quarantine attribute off every file in the .app and
aborts the whole update with EACCES on any read-only one, so a payload
whose baked pyc files were sealed 0444 (f6713f2762) could never pass
a macOS update: three attempts, "Couldn't remove quarantine attribute",
then "Too many attempts to install, aborting update" and the old app
relaunches on the old version. Bake them 0644 instead: unchecked-hash
pycs are never rewritten and asserted coverage means no cache-miss
write can target them, so the read-only bit only ever blocked the
updater.
(cherry picked from commit fa34f089cb6e05bc86c03320eaf0d5e136b96f7d)
First launch of a bundled payload paid a cold-compile stall: the launcher
redirects bytecode writes to a user-level cache (signature-breaking on
macOS, read-only mount on AppImage/MSIX), so every import compiled from
source. Now staging bakes the cache into the payload:
- compileall with the payload's OWN staged 3.14 interpreter, unchecked-
hash pycs: repack mtimes cannot invalidate them, a stale source can
never trigger a rewrite, and read-only pycs mean the macOS signature
never observes a change. Dirs stay writable — in-place rebuilds
rmtree the tree; asserted coverage plus unchecked-hash means no
cache-miss write can target them.
- coverage is the perf contract: the bake FAILS if any parseable module
lacks a pyc (empirically 0 unparseable files ship, so compileall is
strict). Probe suite: py_compile/cache_from_source, PEP 552 flags,
multi-root read, stale-source no-rewrite, read-only cache-dir import.
- launcher: the baked marker makes configure() leave sys.pycache_prefix
UNSET — the prefix relocates reads too and would hide the baked pycs.
Payload modules read their source-adjacent cache (Python's default
multi-root lookup); plugin/user modules keep caching beside their own
sources under HERMES_HOME. Unmarked payloads keep the old redirect.
- snapshot(): the sealed payload ships without tests/website/evals/
.github/nix/docker/tests-js (~69MB, 46% of tracked bytes) and without
apps/ui-tui/web/scripts — CI prebuilds those products, and
is_bundled_payload routes sealed updates to the channel updater, so
the rebuild graph never runs in a bundle (linux_desktop_entry degrades
to the themed icon). Frontend product staging keeps the full tree.
- test_bundle_native now stages the FULL relocatable toolchain (a bare
interpreter ELF falls back to its compile-time /install prefix and
cannot create a venv), and runs on the real 3.14 for the first time
this campaign — the whole battery had been running 3.12 against the
3.14-pinned lock.