The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(build): remove superseded launcher templates
ethernet0a3a189235ed
diff --git a/scripts/bundles/launcher_wrapper.py b/scripts/bundles/launcher_wrapper.pydeleted file mode 100644index d167f908370..00000000000--- a/scripts/bundles/launcher_wrapper.py+++ /dev/null@@ -1,107 +0,0 @@-"""Bundled-payload CLI entry wrapper — the distlib launcher's zip overlay.--scripts/bundles/payload.py reads this file, substitutes the four-HERMES_* placeholders (see the constants below), and hands the result to-a distlib ScriptMaker as-the script text. On win32 the minted artifact is a real PE: the distlib-launcher stub + a shebang whose interpreter is the ``<launcher_dir>``-placeholder form (resolved at runtime relative to the launcher's own-directory) + this script packed as __main__.py in a zip overlay. The-The wrapper replaces everything the old rust shim + its sidecar did-(plan: pm-clean):-- * resolve the launcher's own directory from sys.argv[0] (the distlib- launcher puts its exe path there — the shebang's ``<launcher_dir>``- placeholder resolves the interpreter the same way),- * put the payload repo snapshot FIRST and the venv site-packages second- on sys.path (same order, same reason as the old shim: the repo's- hermes_cli wins over anything stale in site-packages — the sealed- payload's venv has no working editable install, its pointer names the- BUILD machine),- * drop inherited PYTHONPATH / PYTHONHOME so foreign installs can never- shadow the bundle,- * default sys.pycache_prefix to the user-level cache (%LOCALAPPDATA%- \\hermes\\pycache on win32, ~/.cache/hermes-pycache elsewhere) when the- user has not set one — the sealed payload must never see __pycache__- writes (signature-breaking on mac, read-only mount on AppImage/MSIX).--The whole file is import-safe so tests can drive configure()/main()-directly (tests/scripts/test_desktop_cli_wrapper.py).-"""--import importlib-import os-import sys--HERMES_ENTRY_MODULE = "__HERMES_ENTRY_MODULE__"-HERMES_ENTRY_FUNC = "__HERMES_ENTRY_FUNC__"-HERMES_REPO_REL = "__HERMES_REPO_REL__"-HERMES_SITE_REL = "__HERMES_SITE_REL__"---def _join_rel(here, rel):- """Join a forward-slash relative path (the minted-in convention, same- as the payload manifest) onto a host dir without os.sep assumptions."""- return os.path.join(here, *rel.split("/"))---def launcher_dir(argv0):- """The directory of the launcher itself, from sys.argv[0]. abspath- because cwd is meaningless for a GUI/alias launch."""- return os.path.dirname(os.path.abspath(argv0))---def payload_sys_paths(here):- """Import roots for the sealed payload: repo first (wins), then the- venv's dependency tree — mirroring the old shim's PYTHONPATH order."""- return [_join_rel(here, HERMES_REPO_REL), _join_rel(here, HERMES_SITE_REL)]---def default_pycache_dir(environ):- """User-level bytecode cache. The sealed payload is read-only at- runtime (or signature-sealed, on mac), so __pycache__ writes must- land outside it. Only consulted when the user has not set their own- PYTHONPYCACHEPREFIX."""- if sys.platform == "win32":- base = environ.get("LOCALAPPDATA")- return os.path.join(base, "hermes", "pycache") if base else None- base = environ.get("HOME")- return os.path.join(base, ".cache", "hermes-pycache") if base else None---def configure(here, environ=None):- """Point THIS process (the minted launcher's python) at the payload.- Returns the sys.path entries prepended, for tests."""- environ = os.environ if environ is None else environ- # Same hygiene as the old rust shim: an inherited PYTHONPATH could- # shadow bundled modules with foreign ones; PYTHONHOME would repoint- # the stdlib entirely.- environ.pop("PYTHONPATH", None)- environ.pop("PYTHONHOME", None)- entries = payload_sys_paths(here)- sys.path[0:0] = entries- if not environ.get("PYTHONPYCACHEPREFIX"):- default = default_pycache_dir(environ)- if default:- environ["PYTHONPYCACHEPREFIX"] = default- # The env var is only read at interpreter startup; we ARE at- # startup, but setting it in os.environ cannot retro-activate- # it — sys.pycache_prefix is the live switch.- sys.pycache_prefix = default- return entries---def main(argv=None):- argv = list(sys.argv if argv is None else argv)- here = launcher_dir(argv[0] if argv else sys.argv[0])- configure(here)- importlib.import_module("hermes_bootstrap")- module = importlib.import_module(HERMES_ENTRY_MODULE)- target = getattr(module, HERMES_ENTRY_FUNC)- # main() reads sys.argv; hand it the real argv (argv[0] stays the- # launcher path, exactly like a console-script entry point).- return target()---if __name__ == "__main__":- sys.exit(main())diff --git a/scripts/bundles/mint_launchers.py b/scripts/bundles/mint_launchers.pydeleted file mode 100644index f19989b8226..00000000000--- a/scripts/bundles/mint_launchers.py+++ /dev/null@@ -1,111 +0,0 @@-"""Mint the bundled payload's win32 CLI launchers with distlib.--Run by scripts/bundles/desktop.py (step 5b) with the payload's OWN-store python as the minting interpreter — the store python is the same-distribution the launchers will execute, and its architecture is by-construction the target architecture, which is exactly what distlib's-_get_launcher needs (it picks a 32/64-bit, -arm-suffixed launcher stub by-the MINTING interpreter's platform; cross-arch minting with a mismatched-host python produces launchers that cannot run).--distlib availability: the payload python ships pip (python-build-standalone-includes it), and pip vendors distlib at pip._vendor.distlib — so the mint-works with NO extra dependency. A top-level distlib install is preferred-when present. (Self-contained .\_pth interpreters were REJECTED as an-alternative approach: they break uv venv materialization.)--Layout facts arrive via environment from scripts/bundles/payload.py:-- HERMES_MINT_BIN_DIR absolute output dir (agent-payload/bin)- HERMES_MINT_SPECS JSON list of {"name": exe stem, "module": dotted- module, "func": entry function} — mirrors- [project.scripts] in pyproject.toml- HERMES_MINT_WRAPPER path of the RENDERED launcher-wrapper.py for THIS- entry (substitution is scripts/bundles/payload.py's job,- one implementation, one test)- HERMES_MINT_PYTHON bin-relative path of the store python, BACKslashes,- e.g. <launcher_dir>\..\tools\<entry>\python.exe —- baked into the shebang; the literal <launcher_dir>- prefix is resolved by the launcher at run time- relative to its own directory (relocatability is- live-proved: the placeholder survives minting)--Testable standalone: tests/scripts/test_mint_launchers.py drives main()-against a temp tree with a stub module and RUNS the minted exe.-"""--from __future__ import annotations--import json-import os--try: # a real distlib install when available- from distlib.scripts import ScriptMaker-except ImportError: # the payload python's guaranteed fallback: pip's vendor- from pip._vendor.distlib.scripts import ScriptMaker---def make_maker(bin_dir, shebang_python, wrapper_text):- class MintScriptMaker(ScriptMaker):- # The wrapper text is fully pre-rendered, so ignore the entry the- # spec carried — the name is all we need from it.- def __init__(self, wrapper, **kwargs):- target_dir = kwargs.pop("target_dir")- super().__init__(None, target_dir, **kwargs)- self._wrapper_text = wrapper-- def _get_script_text(self, entry):- return self._wrapper_text-- # The shebang the launcher stub parses: #! + this string. The- # <launcher_dir> literal is replaced by the launcher with its own- # directory at run time — that IS the self-relative mechanism.- maker = MintScriptMaker(- wrapper_text,- target_dir=bin_dir,- add_launchers=True,- dry_run=False,- )- maker.executable = shebang_python- return maker---def mint_one(bin_dir, shebang_python, wrapper_text, spec):- """Mint one launcher exe; returns its absolute path. distlib also- writes a python-versioned twin (hermes-3.14.exe) — the payload ships- exactly one name per entry, so the twin is removed."""- maker = make_maker(bin_dir, shebang_python, wrapper_text)- filenames = maker.make(f"{spec['name']} = {spec['module']}:{spec['func']}")- plain = os.path.join(bin_dir, f"{spec['name']}.exe")- if os.path.abspath(plain) not in (os.path.abspath(f) for f in filenames):- raise SystemExit(f"distlib did not write {plain}: {filenames}")- for extra in filenames:- if os.path.abspath(extra) != os.path.abspath(plain):- os.remove(extra)- return plain---def main(environ=None):- environ = os.environ if environ is None else environ- bin_dir = environ["HERMES_MINT_BIN_DIR"]- specs = json.loads(environ["HERMES_MINT_SPECS"])- shebang_python = environ["HERMES_MINT_PYTHON"]- if not os.path.isabs(bin_dir):- raise SystemExit("HERMES_MINT_BIN_DIR must be absolute")- if not shebang_python.startswith("<launcher_dir>\\..\\"):- raise SystemExit(- "HERMES_MINT_PYTHON must be <launcher_dir>\\..\\payload-relative "- f"(backslashes), got: {shebang_python}"- )- os.makedirs(bin_dir, exist_ok=True)- minted = []- for spec in specs:- # utf-8-sig: tolerate a BOM the JS renderer might prepend.- with open(environ["HERMES_MINT_WRAPPER"], encoding="utf-8-sig") as f:- wrapper_text = f.read()- minted.append(mint_one(bin_dir, shebang_python, wrapper_text, spec))- return minted---if __name__ == "__main__":- print("\n".join(main()))