Spaces:
Running on Zero
Running on Zero
Download deploy/macos_dev_env.sh from Pawan2605/controlplane-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/Pawan2605/controlplane-ai/resolve/main/deploy/macos_dev_env.sh
- Command line
-
hf download hf://spaces/Pawan2605/controlplane-ai/deploy/macos_dev_env.sh
-
curl -L -o macos_dev_env.sh https://huggingface.co/spaces/Pawan2605/controlplane-ai/resolve/main/deploy/macos_dev_env.sh
1.85 kB
| # macOS local development only (NOT used in Docker / on the Space). | |
| # | |
| # torch, faiss-cpu and scikit-learn each bundle their own libomp.dylib and the | |
| # xgboost wheel loads Homebrew's. Four OpenMP runtimes in one process segfault | |
| # (exit 139) as soon as models load in a worker thread. Fix: point every copy at | |
| # torch's libomp and make the dynamic loader resolve `@rpath/libomp.dylib` there. | |
| # | |
| # source deploy/macos_dev_env.sh # after: python3.12 -m venv .venv && pip install -r deploy/requirements.txt | |
| # python start.py | |
| # | |
| # Launch python DIRECTLY from the shell where you sourced this. macOS strips | |
| # DYLD_LIBRARY_PATH when a protected system binary runs (nohup, sudo, env, open, | |
| # /bin/sh -c ...), so `nohup python start.py` loads Homebrew's libomp again and | |
| # segfaults in the warm-up thread. | |
| # works when sourced from bash OR zsh (the macOS default shell) | |
| if [ -n "${BASH_SOURCE:-}" ]; then | |
| _cp_here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | |
| elif [ -n "${ZSH_VERSION:-}" ]; then | |
| _cp_here="$(cd "$(dirname "$(eval 'echo "${(%):-%x}"')")/.." && pwd)" | |
| else | |
| _cp_here="$PWD" | |
| fi | |
| VENV="${VENV:-$_cp_here/.venv}" | |
| SP="$VENV/lib/python3.12/site-packages" | |
| if [ ! -f "$SP/torch/lib/libomp.dylib" ]; then | |
| echo "torch not found in $VENV - create the venv and install deploy/requirements.txt first" >&2 | |
| return 1 2>/dev/null || exit 1 | |
| fi | |
| for d in faiss/.dylibs sklearn/.dylibs; do | |
| if [ -f "$SP/$d/libomp.dylib" ] && [ ! -L "$SP/$d/libomp.dylib" ]; then | |
| mv "$SP/$d/libomp.dylib" "$SP/$d/libomp.dylib.orig" | |
| ln -s "$SP/torch/lib/libomp.dylib" "$SP/$d/libomp.dylib" | |
| echo "unified $d/libomp.dylib -> torch/lib/libomp.dylib" | |
| fi | |
| done | |
| export DYLD_LIBRARY_PATH="$SP/torch/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" | |
| export PATH="$VENV/bin:$PATH" | |
| echo "macOS dev env ready (DYLD_LIBRARY_PATH -> torch/lib)" | |