install.sh 705 B

12345678910111213141516
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
  4. BASE="${PYTHON_BIN:-python3.10}"
  5. if ! command -v "$BASE" >/dev/null 2>&1; then
  6. echo "未找到Python 3.10;请设置PYTHON_BIN为已有Python 3.10的路径。" >&2
  7. exit 1
  8. fi
  9. "$BASE" -c 'import sys; assert sys.version_info[:2] == (3, 10), "需要Python 3.10"'
  10. if [ ! -x .venv/bin/python ]; then
  11. "$BASE" -m venv .venv
  12. fi
  13. .venv/bin/python -m pip install --upgrade pip --timeout 120
  14. .venv/bin/python -m pip install -r requirements.txt --timeout 120
  15. .venv/bin/python -m pip install torch==2.12.1 --index-url https://download.pytorch.org/whl/cpu --timeout 120
  16. echo "依赖安装完成。运行 bash test.sh 验证部署。"