16 lines
709 B
Bash
16 lines
709 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
root=${1:?Usage: Setup-Python.sh APPLICATION_DIRECTORY [--sam2]}
|
|
root=$(cd "$root" && pwd)
|
|
bootstrap=${PYTHON:-python3}
|
|
"$bootstrap" -m venv "$root/python"
|
|
python="$root/python/bin/python3"
|
|
"$python" -m pip install --upgrade pip
|
|
"$python" -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
|
"$python" -m pip install -r "$root/tools/requirements.txt"
|
|
if [ "${2:-}" = --sam2 ]; then
|
|
"$python" -m pip install wheel huggingface_hub
|
|
SAM2_BUILD_CUDA=0 "$python" -m pip install --no-build-isolation 'git+https://github.com/facebookresearch/sam2.git@2b90b9f5ceec907a1c18123530e92e794ad901a4'
|
|
fi
|
|
printf 'Python runtime ready: %s\n' "$python"
|