Skip to content
Python

Intel Mac builds: link OpenSSL statically into cryptography

Rohit C Prasad924358016cf6
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d1421df1..1d1ac904 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -86,6 +86,14 @@ jobs:
# openshell: grpcio, without which the macOS sidecar cannot use OpenShell
# sandboxes (build_dmg.sh refuses to build without it). Not used on Windows.
if [ "$RUNNER_OS" = "Windows" ]; then EXTRAS=bedrock; else EXTRAS=bedrock,openshell; fi
+ # Intel Mac: cryptography ships no wheel for it any more, so pip builds it from
+ # source against Homebrew's OpenSSL, linked dynamically. PyInstaller then bundles
+ # that libssl AND Python's own older one under the same name, the old one wins,
+ # and the program dies on import ("Symbol not found: _SSL_get0_group_name"; the
+ # 0.3.0 and 0.3.1 Intel apps shipped this way). Link OpenSSL in statically.
+ if [ "$RUNNER_OS" = "macOS" ] && [ "$(uname -m)" = "x86_64" ]; then
+ export OPENSSL_STATIC=1 OPENSSL_DIR="$(brew --prefix openssl@3)"
+ fi
"$VPY" -m pip install -e ".[$EXTRAS]" pyinstaller typer tzdata
"$VPY" -c "import aisuite, coworker" # fail fast if either import breaks
diff --git a/coworker/server/run.py b/coworker/server/run.py
index 56ea9912..16ad182a 100644
--- a/coworker/server/run.py
+++ b/coworker/server/run.py
@@ -191,6 +191,11 @@ def main(argv=None) -> None:
),
)
parser.add_argument("--host", default=cfg.host)
+ parser.add_argument(
+ "--check",
+ action="store_true",
+ help="build the application and exit without serving (packaging checks)",
+ )
parser.add_argument("--port", type=int, default=cfg.port)
args = parser.parse_args(argv)
if args.allow_dangerous_mode:
@@ -202,6 +207,14 @@ def main(argv=None) -> None:
# target this process, not config.port. The desktop shell runs the sidecar on
# port 8765, or a free port when that is taken (a hand-run server), so the
# managed-connect redirect must follow the real port, not the 8765 default.
+ if args.check:
+ # Every import and the application wiring, nothing bound, nothing written: a
+ # frozen build that cannot load its libraries fails here (the 0.3.0 and 0.3.1
+ # Intel apps shipped with a sidecar that could not).
+ build_app(args.cwd, args.model, args.mode)
+ print("ok")
+ return
+
os.environ["COWORKER_PORT"] = str(args.port)
generated_token_path = _ensure_api_token(args.port)
try:
diff --git a/packaging/build_dmg.sh b/packaging/build_dmg.sh
index 76f5dad4..516e5a04 100755
--- a/packaging/build_dmg.sh
+++ b/packaging/build_dmg.sh
@@ -115,6 +115,10 @@ if [ -n "$(find "$GUI/src-tauri/binaries/sidecar" -type d -name "*.framework" |
exit 1
fi
chmod +x "$GUI/src-tauri/binaries/sidecar/openworker-server"
+# Start it once, against an empty state folder: a sidecar that cannot load its libraries
+# must fail the build here, not on the user's Mac (the 0.3.0 and 0.3.1 Intel apps shipped
+# with a sidecar that could not; `--help` alone did not reach the broken import).
+COWORKER_STATE_DIR="$(mktemp -d)" "$GUI/src-tauri/binaries/sidecar/openworker-server" --check
# Sign the sidecar's Mach-O files BEFORE tauri build: `tauri build` signs the .app (sealing
# resources into its signature) but does NOT sign nested binaries inside resources — unsigned
diff --git a/tests/test_server.py b/tests/test_server.py
index 08c3b8be..d7a63529 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -505,6 +505,26 @@ def test_server_sets_explicit_websocket_frame_limit(tmp_path, monkeypatch):
assert seen["ws_max_size"] == server_run._WS_MAX_FRAME_BYTES
+def test_check_flag_builds_the_app_and_serves_nothing(tmp_path, monkeypatch, capsys):
+ """The packaging check: every import and the wiring, no port, no token file. Added
+ after the Intel apps shipped with a sidecar that died on its first import."""
+ import sys
+
+ from coworker.server import run as server_run
+
+ built = []
+ monkeypatch.setattr(server_run, "_ensure_ca_bundle", lambda: None)
+ monkeypatch.setattr(server_run, "build_app", lambda *args: built.append(args) or object())
+ monkeypatch.setattr(server_run, "_ensure_api_token", lambda port: pytest.fail("a check must not write a token"))
+ monkeypatch.delitem(sys.modules, "uvicorn", raising=False)
+ monkeypatch.setattr(server_run, "_exit_when_orphaned", lambda: pytest.fail("a check must not serve"))
+
+ server_run.main(["--cwd", str(tmp_path), "--check"])
+
+ assert len(built) == 1 and built[0][0] == str(tmp_path)
+ assert capsys.readouterr().out.strip() == "ok"
+
+
def test_standalone_server_token_file_is_user_only(tmp_path, monkeypatch):
import os