Skip to content

Commit 6b82b71

Browse files
committed
fix: universal2 dispatcher arch flags + WASM skip guards
1 parent d8a8a41 commit 6b82b71

4 files changed

Lines changed: 29 additions & 17 deletions

File tree

build_hooks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434

3535

3636
def _run_post_install():
37+
# ADD THIS CHECK AT THE TOP
38+
if sys.platform in ('emscripten', 'wasm32'):
39+
print(" [build_hooks] WASM environment detected, skipping C dispatcher build.")
40+
return
3741
marker = Path(sys.executable).parent / ".omnipkg_dispatch_compiled"
3842
if marker.exists():
3943
marker.unlink()

pyproject.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ classifiers = [
3939
]
4040

4141
dependencies = [
42-
"uv_ffi>=0.10.8.post7 ; python_version >= '3.8' and python_version <= '3.14'",
42+
"uv_ffi>=0.10.8.post7 ; python_version >= '3.8' and python_version <= '3.14' and platform_system != 'Emscripten'",
4343
"requests>=2.20",
44-
"psutil>=5.9.0",
44+
"psutil>=5.9.0 ; platform_system != 'Emscripten'",
4545
"typer>=0.4.0",
4646
"rich>=10.0.0",
4747

@@ -92,10 +92,11 @@ dependencies = [
9292
# cryptography - version split by Python
9393
# Python 3.7: stuck at 45.0.7 (upstream dropped 3.7 before 46.x)
9494
# CVEs unresolved: CVE-2026-26007 (HIGH), CVE-2026-34073 (LOW), CVE-2026-39892 (MODERATE)
95-
# TODO: cryptography-lts needed for py37 to backport fixes landing in 46.0.5–46.0.7
96-
"cryptography>=45.0.7,<46.0; python_version == '3.7'", # UNSAFE: 3 open CVEs, best available
97-
"cryptography>=46.0.7; python_version >= '3.8'", # fully patched
98-
95+
# TODO: cryptography-lts needed for py37 to backport fixes landing in 46.0.5–46.0.7
96+
"cryptography>=46.0.7 ; python_version >= '3.8' and platform_system != 'Emscripten'", # fully patched
97+
"cryptography>=45.0.7,<46.0 ; python_version == '3.7' and platform_system != 'Emscripten'", # UNSAFE: 3 open CVEs, best available
98+
"cryptography-wasm>=42.0.2 ; platform_system == 'Emscripten'",
99+
99100
# Security scanning
100101
# safety moved to optional 'audit' extra due to CVE-2025-14009 in nltk dependency
101102
# pip-audit is now the primary default scanner for all versions

setup.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616
import sys
1717
import subprocess
1818
import shutil
19+
import platform
1920
from pathlib import Path
2021

22+
# Automatically detect WASM environment and skip all C compilation
23+
IS_WASM = sys.platform in ('emscripten', 'wasm32')
24+
if IS_WASM:
25+
os.environ['OMNIPKG_SKIP_C_EXT'] = '1'
26+
2127
SKIP_C_EXTENSIONS = os.environ.get('OMNIPKG_SKIP_C_EXT', '0') == '1'
2228

2329
# ── Dispatcher binary install (shared by both install and develop commands) ──
@@ -43,21 +49,22 @@ def _install_dispatcher_binary(install_dir=None):
4349
install_dir = Path(sys.executable).parent # $VENV/bin
4450

4551
binary_out = Path(install_dir) / "_omnipkg_dispatch_bin"
46-
47-
# 1. FIX: Create the wheel's scripts directory so GCC doesn't crash
4852
binary_out.parent.mkdir(parents=True, exist_ok=True)
4953

54+
cmd = ["gcc", "-O2"]
55+
if sys.platform == "darwin":
56+
archflags = os.environ.get("ARCHFLAGS", "")
57+
if archflags:
58+
cmd.extend(archflags.split())
59+
elif platform.machine() == "arm64":
60+
cmd.extend(["-arch", "x86_64", "-arch", "arm64"])
61+
cmd.extend(["-o", str(binary_out), str(c_source)])
62+
5063
try:
51-
result = subprocess.run(
52-
["gcc", "-O2", "-o", str(binary_out), str(c_source)],
53-
capture_output=True, text=True
54-
)
64+
result = subprocess.run(cmd, capture_output=True, text=True)
5565
if result.returncode != 0:
5666
print(f" [dispatcher] Compilation failed, using Python dispatcher:")
57-
subprocess.run(["gcc", "-v", "-O2", "-o", str(binary_out), str(c_source)],
58-
capture_output=False,
59-
text=True
60-
)
67+
subprocess.run(cmd + ["-v"], capture_output=False, text=True)
6168
return
6269

6370
import time

0 commit comments

Comments
 (0)