#!/bin/bash # ============================================================================ # install.sh — create an isolated venv (Python 3.12) and install wiki-kb # ============================================================================ set -euo pipefail readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly VENV_DIR="${SCRIPT_DIR}/.venv" # Python 3.12 is pinned because fastembed/onnxruntime wheels lag on newer # interpreters. Prefer pyenv's 3.12, fall back to any python3.12 on PATH. find_python() { local candidates=( "${HOME}/.pyenv/versions/3.12.8/bin/python3.12" "$(command -v python3.12 || true)" ) local p for p in "${candidates[@]}"; do if [[ -n "$p" && -x "$p" ]]; then printf '%s\n' "$p" return 0 fi done echo "Error: python3.12 not found (need it for fastembed/onnxruntime wheels)." >&2 echo "Install it, e.g.: pyenv install 3.12.8" >&2 return 1 } main() { local py py="$(find_python)" echo "Using interpreter: $py ($("$py" --version))" if [[ ! -d "$VENV_DIR" ]]; then echo "Creating venv at $VENV_DIR" "$py" -m venv "$VENV_DIR" fi # shellcheck disable=SC1091 source "${VENV_DIR}/bin/activate" python -m pip install --quiet --upgrade pip echo "Installing wiki-kb (+dev extras)..." python -m pip install --quiet -e "${SCRIPT_DIR}[dev]" echo "Done. Activate with: source ${VENV_DIR}/bin/activate" } main "$@"