From 60110eeb0a3eb39c03182a5871182f5f6b09bcb3 Mon Sep 17 00:00:00 2001 From: James Pine Date: Fri, 17 Apr 2026 18:14:11 -0700 Subject: [PATCH] fix(build): pass PyInstaller hook paths relative so .spec is portable Absolute paths ended up in the auto-regenerated voicebox-server.spec because build_binary.py prefixed every --runtime-hook and --additional-hooks-dir with str(backend_dir / ...). That broke builds on any machine whose checkout wasn't at /Users/jamie/... and anyone invoking pyinstaller voicebox-server.spec directly. os.chdir(backend_dir) already runs before PyInstaller (same reason server.py works as a bare filename), so the backend_dir prefix is unnecessary. Drop it so the generated spec references pyi_hooks/, pyi_rth_numpy_compat.py, pyi_rth_torch_compiler_disable.py as repo- relative paths. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/build_binary.py | 9 ++++++--- backend/voicebox-server.spec | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/build_binary.py b/backend/build_binary.py index 2df2ceb2..875d6733 100644 --- a/backend/build_binary.py +++ b/backend/build_binary.py @@ -55,20 +55,23 @@ def build_server(cuda=False): # numpy 2.x / torch ABI mismatch fix: install memmove fallback for # torch.from_numpy() before the app starts. Runtime hooks run after # FrozenImporter is registered so frozen torch/numpy are importable. + # Paths are passed relative to backend_dir because os.chdir(backend_dir) + # runs before PyInstaller. Absolute paths would get baked into the + # generated .spec, breaking reproducible builds on other machines / CI. args.extend( [ "--runtime-hook", - str(backend_dir / "pyi_rth_numpy_compat.py"), + "pyi_rth_numpy_compat.py", # Stub torch.compiler.disable before transformers imports # flex_attention, which otherwise triggers torch._dynamo → # torch._numpy._ufuncs and crashes at module load under # PyInstaller. See pyi_rth_torch_compiler_disable.py. "--runtime-hook", - str(backend_dir / "pyi_rth_torch_compiler_disable.py"), + "pyi_rth_torch_compiler_disable.py", # Per-module collection overrides (e.g. forcing scipy.stats._distn_infrastructure # to bundle .py source alongside .pyc so the runtime hook can source-patch it). "--additional-hooks-dir", - str(backend_dir / "pyi_hooks"), + "pyi_hooks", ] ) diff --git a/backend/voicebox-server.spec b/backend/voicebox-server.spec index 4f7f49b7..ab8566c8 100644 --- a/backend/voicebox-server.spec +++ b/backend/voicebox-server.spec @@ -58,9 +58,9 @@ a = Analysis( binaries=binaries, datas=datas, hiddenimports=hiddenimports, - hookspath=['/Users/jamie/Projects/spacedriveapp/voicebox/backend/pyi_hooks'], + hookspath=['pyi_hooks'], hooksconfig={}, - runtime_hooks=['/Users/jamie/Projects/spacedriveapp/voicebox/backend/pyi_rth_numpy_compat.py', '/Users/jamie/Projects/spacedriveapp/voicebox/backend/pyi_rth_torch_compiler_disable.py'], + runtime_hooks=['pyi_rth_numpy_compat.py', 'pyi_rth_torch_compiler_disable.py'], excludes=['nvidia', 'nvidia.cublas', 'nvidia.cuda_cupti', 'nvidia.cuda_nvrtc', 'nvidia.cuda_runtime', 'nvidia.cudnn', 'nvidia.cufft', 'nvidia.curand', 'nvidia.cusolver', 'nvidia.cusparse', 'nvidia.nccl', 'nvidia.nvjitlink', 'nvidia.nvtx'], noarchive=False, optimize=0,