[eric] Mac publish fixes: NODE_OPTIONS heap + rsync excludes for user-state and template_cache

This commit is contained in:
ciregenz
2026-05-14 01:42:31 -07:00
parent 531e3df28f
commit 5d3cfcec2d
2 changed files with 38 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
"""Module alias — exposes the `debug()` function under the `swarm_debug`
name so code that does `from swarm_debug import debug` resolves to the
same OpenSwarm-bundled package that the legacy `import debug` path
already serves.
`debug.py` ends with `sys.modules[__name__] = debug`, which replaces the
module object with the bare function. That trick lets OpenSwarm's own
code write `import debug; debug(x)` (the imported name binds to the
function directly), but it means `from debug import debug` doesn't work
(you can't attribute-walk a function). This shim captures the function
via `import debug` (which now binds to the function thanks to the
sys.modules swap) and re-exports it as a normal module attribute, so
the more conventional `from swarm_debug import debug` pattern works.
"""
import debug as _debug # noqa: F401 — `_debug` is actually the function
# Re-export as a module attribute so `from swarm_debug import debug` resolves.
debug = _debug
__all__ = ["debug"]
+17
View File
@@ -367,9 +367,19 @@ rsync -a \
--exclude='__pycache__' --exclude='**/__pycache__' \
--exclude='*.pyc' --exclude='.venv' \
--exclude='data/tools' \
--exclude='data/outputs_workspace' \
--exclude='data/agent_history' --exclude='data/sessions' \
--exclude='apps/outputs/webapp_template_cache' \
--exclude='tests' --exclude='**/tests' \
--exclude='/.env' --exclude='/.env.*' \
"$PROJECT_ROOT/backend/" "$STAGING_DIR/backend/"
# webapp_template_cache: a pre-built node_modules.tar.gz that gets shipped
# to speed up first-app-create. Apple notarization extracts it and rejects
# the build because upstream native binaries inside (esbuild, fsevents, etc.)
# aren't signed with our Developer ID. Backend's _try_extract_bundled_archive
# in view_builder_templates.py falls through cleanly when the archive is
# missing, so first-app create just runs `npm install` (about 90s extra).
# Long-term fix: sign native binaries before tarring in build-template-archive.sh.
# Note: .env exclude is anchored to the backend/ source root (`/.env` /
# `/.env.*`), not recursive. The vendored webapp-template snapshot at
# backend/apps/outputs/webapp_template/.env.example MUST be shipped so
@@ -424,6 +434,13 @@ echo "[5/5] Packaging with electron-builder..."
cd "$PROJECT_ROOT/electron"
npm install
# Node's default ~4 GB heap OOMs while codesign'ing the .app on dual-arch
# publish runs (the .app is ~4.8 GB and electron-builder walks every file
# to hash + sign, holding paths + metadata in memory). Bump the old-space
# ceiling so V8 has headroom; 12 GB covers both arches in one invocation.
# Caller's NODE_OPTIONS is respected if already set.
export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=12288}"
if $PUBLISH_MODE; then
npx electron-builder --mac --arm64 --x64 --publish always
elif $SIGN_MODE; then