| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/sh
- # Install the bundled Kylin ARM64 CPU wheels into a new project environment.
- set -eu
- if [ "$#" -ne 1 ]; then
- echo 'Usage: sh install_offline_env.sh /absolute/project/path' >&2
- exit 2
- fi
- case "$1" in
- /*) PROJECT_ROOT=$1 ;;
- *) echo 'Project path must be absolute.' >&2; exit 2 ;;
- esac
- case "$0" in
- */*) BUNDLE_DIR=${0%/*} ;;
- *) BUNDLE_DIR=. ;;
- esac
- BUNDLE_DIR=$(CDPATH= cd -- "$BUNDLE_DIR" && pwd)
- PROJECT_ROOT=$(CDPATH= cd -- "$PROJECT_ROOT" && pwd)
- [ -f "$PROJECT_ROOT/pyproject.toml" ] && [ -f "$PROJECT_ROOT/uv.lock" ] || {
- echo 'Project pyproject.toml and uv.lock are required.' >&2
- exit 1
- }
- [ ! -e "$PROJECT_ROOT/.venv" ] || {
- echo 'Project .venv already exists; inspect it before retrying.' >&2
- exit 1
- }
- PYTHON_BIN=${PYTHON_BIN:-python3.14}
- command -v "$PYTHON_BIN" >/dev/null 2>&1 || {
- echo 'Python 3.14 is required; set PYTHON_BIN to its executable path if needed.' >&2
- exit 1
- }
- "$PYTHON_BIN" - <<'PY'
- import platform
- import sys
- import sysconfig
- libc, version = platform.libc_ver()
- if (sys.version_info[:2] != (3, 14) or platform.machine().lower() != 'aarch64'
- or libc != 'glibc' or tuple(map(int, version.split('.')[:2])) < (2, 28)
- or sysconfig.get_config_var('Py_GIL_DISABLED')):
- raise SystemExit('Requires standard CPython 3.14 on aarch64 with glibc >= 2.28.')
- print('Target Python and platform preflight passed.')
- PY
- (cd "$BUNDLE_DIR" && sha256sum -c SHA256SUMS >/dev/null)
- echo 'Bundle SHA256 checks passed.'
- chmod +x "$BUNDLE_DIR/uv"
- export UV_CACHE_DIR="$PROJECT_ROOT/.uv-cache"
- export UV_LINK_MODE=copy
- "$BUNDLE_DIR/uv" --no-config --offline venv --no-python-downloads \
- --python "$(command -v "$PYTHON_BIN")" "$PROJECT_ROOT/.venv"
- "$BUNDLE_DIR/uv" --no-config --offline pip install \
- --python "$PROJECT_ROOT/.venv/bin/python" --no-index \
- --find-links "$BUNDLE_DIR/wheelhouse" \
- --requirement "$BUNDLE_DIR/requirements-arm64-cpu.txt"
- "$BUNDLE_DIR/uv" --no-config --offline pip check \
- --python "$PROJECT_ROOT/.venv/bin/python"
- "$PROJECT_ROOT/.venv/bin/python" "$PROJECT_ROOT/scripts/check-runtime.py"
- "$PROJECT_ROOT/.venv/bin/python" -c \
- 'import torch, transformers, pymilvus, redis, langgraph, starlette, uvicorn; print("torch:", torch.__version__, "cuda:", torch.cuda.is_available())'
- HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 \
- "$PROJECT_ROOT/.venv/bin/python" "$PROJECT_ROOT/scripts/deploy_models.py" --check-only
- echo 'Offline Python environment and local model checks passed.'
|