Skip to content
Python

packaging: standalone-repo fixes — venv at repo root, aisuite as a pip dep, keyless builds

Rohit C Prasad7f6f17c197c2
diff --git a/packaging/build_dmg.sh b/packaging/build_dmg.sh
index cade68f5..5902b1cd 100755
--- a/packaging/build_dmg.sh
+++ b/packaging/build_dmg.sh
@@ -9,13 +9,13 @@
#
# Prerequisites (mirrors build_windows.ps1's header):
# - Rust (rustup) + Node/npm, and the GUI deps installed (npm ci in surfaces/gui).
-# - A Python venv at platform/.venv with this package installed editable, plus the
+# - A Python venv at .venv (repo root) with this package installed editable, plus the
# build-only deps:
-# python3 -m venv platform/.venv
-# platform/.venv/bin/pip install -e . pyinstaller tzdata typer
+# python3 -m venv .venv
+# .venv/bin/pip install -e . pyinstaller tzdata typer
# `typer` is needed only at BUILD time: PyInstaller walks the `mcp` package and
# `mcp.cli` calls sys.exit() at import if typer is absent, which aborts the freeze.
-# (aisuite is not pip-installed — the spec adds <repo> to pathex so PyInstaller finds it.)
+# (aisuite installs like any other dependency — git-pinned in pyproject.toml.)
#
# SIGNING: set APPLE_SIGNING_IDENTITY to a "Developer ID Application: … (TEAMID)" identity and
# `tauri build` signs the .app + the bundled sidecar with it. Left unset → UNSIGNED (first launch
@@ -133,7 +133,7 @@ echo "==> [3/5] tauri build (.app)"
# `.ocw-updater.env` one directory above the repo (same convention as the notary env).
# Keyless builds skip the overlay entirely so dev/fork builds keep working; keyless
# RELEASES would strand every install without auto-update, hence the loud warning.
-UPDATER_ENV="${OCW_UPDATER_ENV:-$PLATFORM/../../.ocw-updater.env}"
+UPDATER_ENV="${OCW_UPDATER_ENV:-$PLATFORM/../.ocw-updater.env}"
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ] && [ -f "$UPDATER_ENV" ]; then
# shellcheck disable=SC1090
source "$UPDATER_ENV"
@@ -144,7 +144,9 @@ if [ -n "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
else
echo " WARNING: no updater signing key — building WITHOUT auto-update artifacts (not releasable)."
fi
-( cd "$GUI" && npm run tauri build -- --bundles app "${UPDATER_OVERLAY[@]}" )
+# ${arr[@]+…} guard: plain "${arr[@]}" on an EMPTY array is an "unbound variable"
+# under set -u on macOS's stock bash 3.2 — hit by keyless (fresh-clone) builds.
+( cd "$GUI" && npm run tauri build -- --bundles app ${UPDATER_OVERLAY[@]+"${UPDATER_OVERLAY[@]}"} )
echo "==> [4/5] hdiutil: wrapping into .dmg"
BUNDLE="$GUI/src-tauri/target/release/bundle"
@@ -238,8 +240,7 @@ elif [ -n "${APPLE_SIGNING_IDENTITY:-}" ]; then
NOTARYTOOL_API_KEY_ID="${NOTARYTOOL_API_KEY_ID:-${APPLE_API_KEY:-}}"
NOTARYTOOL_API_ISSUER_ID="${NOTARYTOOL_API_ISSUER_ID:-${APPLE_API_ISSUER:-}}"
- REPO="$(cd "$PLATFORM/.." && pwd)"
- NOTARY_ENV="${OCW_NOTARY_ENV:-$REPO/../.ocw-notary.env}"
+ NOTARY_ENV="${OCW_NOTARY_ENV:-$PLATFORM/../.ocw-notary.env}"
if [ -z "${NOTARYTOOL_API_KEY_PATH:-}" ] && [ -f "$NOTARY_ENV" ]; then
set -a; # shellcheck disable=SC1090
source "$NOTARY_ENV"; set +a
diff --git a/packaging/coworker-server.spec b/packaging/coworker-server.spec
index 4c6cda6f..be397c71 100644
--- a/packaging/coworker-server.spec
+++ b/packaging/coworker-server.spec
@@ -5,8 +5,8 @@ One-DIR bundle (exe + `_internal/` support folder) shipped via Tauri's `resource
It used to be a onefile binary in the externalBin slot, but onefile self-extracts its whole
archive to a temp dir on EVERY launch — 6-7s of "Starting coworker…" splash (measured; the
actual Python import is ~0.5s). The wrinkles handled here:
- - aisuite isn't pip-installed — it lives at <repo>/aisuite on sys.path via a `.pth`. We add
- both the repo root and platform/ to `pathex` and collect coworker + aisuite submodules.
+ - aisuite is a regular pip dependency (git-pinned in pyproject.toml); collect coworker +
+ aisuite submodules from the venv.
- uvicorn loads its protocol/lifespan impls dynamically → collect_all.
- certifi's CA bundle must ship for TLS (OpenAI, web search, Telegram/Slack).
- messaging extras (slack_bolt, telegram) are optional; collected if importable.
@@ -26,10 +26,9 @@ import sys
from PyInstaller.utils.hooks import collect_all, collect_submodules
# SPECPATH is injected by PyInstaller and points at this file's directory
-# (<repo>/platform/packaging). Derive everything else from it — no hardcoded paths.
+# (<repo>/packaging). Derive everything else from it — no hardcoded paths.
PACKAGING = SPECPATH
-PLATFORM = os.path.dirname(PACKAGING)
-ROOT = os.path.dirname(PLATFORM)
+ROOT = os.path.dirname(PACKAGING)
IS_WINDOWS = sys.platform == "win32"
@@ -79,7 +78,7 @@ for pkg in ("slack_bolt", "telegram"): # [messaging] extra — optional
a = Analysis(
[os.path.join(PACKAGING, "server_entry.py")],
- pathex=[ROOT, PLATFORM],
+ pathex=[ROOT],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
diff --git a/packaging/setup_dev_env.sh b/packaging/setup_dev_env.sh
index 0315ca50..ec296547 100644
--- a/packaging/setup_dev_env.sh
+++ b/packaging/setup_dev_env.sh
@@ -1,24 +1,21 @@
#!/usr/bin/env bash
# One-time dev bootstrap for a fresh checkout: creates the Python venv every
-# from-source flow expects at platform/.venv — the browser dev flow runs its
+# from-source flow expects at .venv — the browser dev flow runs its
# coworker-server directly, and the Tauri desktop shell falls back to it when
# no packaged sidecar binary is present (src-tauri/src/lib.rs, resolution step 3).
#
-# Usage: bash platform/packaging/setup_dev_env.sh
+# Usage: bash packaging/setup_dev_env.sh
set -euo pipefail
-ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
-VENV="$ROOT/platform/.venv"
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+VENV="$ROOT/.venv"
python3 -m venv "$VENV"
# The coworker package (server, engine, connectors) + inbound-messaging extras.
+# aisuite comes in as a regular dependency (git-pinned in pyproject.toml until
+# the next PyPI release).
"$VENV/bin/pip" install --quiet --upgrade pip
-"$VENV/bin/pip" install --quiet -e "$ROOT/platform[messaging,dev]"
-
-# `import aisuite` resolves from THIS checkout, not PyPI — a .pth puts the repo
-# root on the venv's path (the packaged app freezes it the same way).
-SITE="$("$VENV/bin/python" -c 'import site; print(site.getsitepackages()[0])')"
-echo "$ROOT" > "$SITE/aisuite_src.pth"
+"$VENV/bin/pip" install --quiet -e "$ROOT[messaging,dev]"
"$VENV/bin/python" -c 'import aisuite, coworker' # fail loudly if the wiring broke
echo "Ready: $VENV"