Repository navigation
Agent: carry the python tool's CPython inside the Windows executable - #1537
Merged
Merged
Conversation
A Windows generation holds exactly four files. The root launcher of every existing installation is never replaced by an in-app update and refuses a generation with anything else, and installed updaters refuse an archive with extra entries. So the runtime cannot sit beside the executable as it does on macOS and Linux without stranding those installations. build-release.sh now prepares the hash-pinned runtime on Windows, packs it (prepare-python.py --archive) and compiles the archive into maple-agent.exe, where the Authenticode signature covers it. Packaging refuses an executable without one. The first python call unpacks it into %LOCALAPPDATA%\<data namespace>\python-runtime\<digest>, a private folder beside store-v1, and later calls reuse it. An interrupted or damaged copy is unpacked again, a new runtime replaces the old copy, and the uninstaller removes the folder. `maple-agent python-check` (hidden) starts the bundled Python the same way and runs one cell, for packaging checks that have no account. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
prepare-python.py requires build Python 3.13. The x64 Windows images default to an older python3, so agent-package-windows and agent-full-windows stopped at that check; the tool cache holds a newer one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On the Windows QA VM the first python call after unpacking missed the worker's 10 s startup deadline: the first start of files Windows has never run is slow. The second call passed. Unpacking now runs the interpreter once, importing what the worker imports, so that one-time cost is not counted against the deadline. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The reuse check looked only at the receipt, manifest, interpreter and worker. On the QA VM a copy without python314.dll was reused and could not start. The receipt now lists every file with its size and reuse checks each one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows packages now carry the CPython runtime the
pythontool runs, so the tool can be switched on there as on macOS (PR #1412) and Linux (PR #1414).Why it is inside the executable
The spec's recommended option was a
runtime/pythonsubtree in each Windows generation. That cannot reach existing installations:maple-agent.exelauncher that NSIS installed checks every generation against that list at startup (scan_generation), and in-app updates never replace it. Every existing installation would refuse a generation with a runtime in it until the user ran a new installer by hand.Inside
maple-agent.exethe runtime needs no updater or launcher change, arrives with installs and in-app updates alike, needs no network on first use, and is covered by the executable's Authenticode signature.What changed
scripts/build-release.sh): on Windows it prepares the hash-pinned runtime for the target, packs it with the newprepare-python.py --archive(sorted, no timestamps, so the same runtime gives the same bytes) and setsMAPLE_CODE_MODE_EMBEDDED_RUNTIME.maple-code-mode's new build script compiles that archive in. Without the variable nothing is embedded, so development builds are unchanged.scripts/windows-release.py): refuses an executable with no embedded runtime.EmbeddedPython,PythonWorkers): the firstpythoncall unpacks the archive into%LOCALAPPDATA%\<data namespace>\python-runtime\<digest>\.store-v1and outside its backups.python-runtime. It is a copy of installed files; user data stays. The rootuninstall.exe, like the launcher, is never replaced by in-app updates, so an installation that only updates in-app keeps its old uninstaller and leaves this folder (56 MB) behind until an installer is run again.maple-agent python-check(hidden): starts the bundled Python the way a task's first call does and runs one cell that imports the native modules and pip. It needs no account, so packaging checks and the QA VM can use it.prepare-python.pyrequires it and the x64 images default to an older one, which also stoppedagent-full-windowson master.Cost
maple-agent.exegrows by about 18.5 MB (x64), in the installer and the updater archive.pythoncall on a machine waits for the unpacking.Not in this PR
python.exeand DLLs are Python Build Standalone's files, without Maple's signature. Signing them would have to happen before the executable is built, and the build job has no signing credentials by design.tar,flate2andsha2were already inCargo.lock.Validation
just cipasses on macOS, with new tests for packing, unpacking, reuse, repair, replacement, unsafe archive paths and the private folder.python-checkpasses on macOS against the runtime beside the executable.ci:packageandci:windows, including the new native Windows test that unpacks the staged runtime and runs a cell from the copy.ci:packagerun (build 685), on thewindows-11QA VM (x64 under emulation, about 20 times slower than hardware, Defender off), installed and run as the desktop user at normal integrity:maple-agent python-checkon a machine with no copy: unpacks 1,985 files into%LOCALAPPDATA%\maple-agent-dev\python-runtime\<digest>and runs the cell (CPython 3.14.7, native modules and pip import). The folder's ACL grants only the user.python314.dllthe copy is unpacked again and the cell runs. An earlier build reused the damaged copy; the receipt change fixes that.python-runtime; install and uninstall twice in a row both clean.windows-11-arm64QA VM (native speed, Defender real-time protection on):python-check: first run unpacks and runs in 7 to 9 s, a second run reuses the copy in 2 to 3 s, and a copy withpython314.dlldeleted is unpacked again. Defender recorded no detection.pythoncalls. The first unpacked the runtime and printed CPython 3.14.7 on ARM64; the second read the first call's variable.🤖 Generated with Claude Code