ACCC1380's picture
download
raw
1.89 kB
#!/usr/bin/env bash
# Always use the user's /tmp/uv-venv. Restore packages from the saved lock.
setup_runtime() {
if ! command -v uv >/dev/null 2>&1; then
echo '缺少 uv;请先安装 uv 后重新运行 start.sh。' >&2
return 1
fi
local runtime_dir=/tmp/uv-venv
if [[ ! -x "$runtime_dir/bin/python" ]]; then
uv venv --python 3.13 --seed "$runtime_dir"
fi
webui_python="$runtime_dir/bin/python"
export VIRTUAL_ENV="$runtime_dir"
export PATH="$runtime_dir/bin:$PATH"
export UV_PYTHON="$webui_python"
export UV_HTTP_TIMEOUT=180
export PIP_CONSTRAINT="$PWD/runtime-constraints.txt"
export UV_CONSTRAINT="$PIP_CONSTRAINT"
export TORCH_COMMAND='pip install torch==2.14.0+cu130 torchvision==0.29.0+cu130 --extra-index-url https://download.pytorch.org/whl/cu130'
local runtime_lock="$PWD/runtime-lock.txt"
if [[ ! -s "$runtime_lock" ]]; then
echo "缺少依赖锁定文件:$runtime_lock;请从备份恢复此文件。" >&2
return 1
fi
# Install instead of sync: this shared environment may contain notebook packages.
# The upstream requirements override Gradio's Pillow/NumPy upper bounds.
# Restore the complete tested snapshot without re-resolving those conflicts.
uv pip install --python "$webui_python" --no-deps -r "$runtime_lock" --extra-index-url https://download.pytorch.org/whl/cu130 --index-strategy unsafe-best-match
if ! "$webui_python" "$PWD/check-runtime.py"; then
echo '运行环境检查失败,正在修复固定版本的 torch/torchvision…'
uv pip install --python "$webui_python" --reinstall-package torch --reinstall-package torchvision torch==2.14.0+cu130 torchvision==0.29.0+cu130 --index-url https://download.pytorch.org/whl/cu130
"$webui_python" "$PWD/check-runtime.py"
fi
export UV_CONSTRAINT="$runtime_lock"
}

Xet Storage Details

Size:
1.89 kB
·
Xet hash:
d17cf45ac45b304432bd73a781268e7c6ef9987a5d30a8575cea81e5eb42ce7e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.