#!/usr/bin/env bash # Deterministic installer for Project_Journal (Python 3.14) # Defaults: CPU profile, no optional NLP model. # # Usage: # ./installreqs.sh # ./installreqs.sh --gpu # ./installreqs.sh --with-nlp # ./installreqs.sh --gpu --with-nlp set -euo pipefail REQ_FILE="requirements_cpu_only.txt" WITH_NLP=0 VENV_DIR=".venv" while [[ $# -gt 0 ]]; do case "$1" in --gpu) REQ_FILE="requirements_gpu.txt" shift ;; --with-nlp) WITH_NLP=1 shift ;; --venv) VENV_DIR="$2" shift 2 ;; -h|--help) echo "Usage: $0 [--gpu] [--with-nlp] [--venv PATH]" exit 0 ;; *) echo "Unknown option: $1" >&2 echo "Usage: $0 [--gpu] [--with-nlp] [--venv PATH]" exit 1 ;; esac done if [[ ! -f "$REQ_FILE" ]]; then echo "Error: $REQ_FILE not found." >&2 exit 1 fi echo "Creating/updating virtual environment at: $VENV_DIR" python3.14 -m venv "$VENV_DIR" # shellcheck disable=SC1090 source "$VENV_DIR/bin/activate" python -m pip install --upgrade pip setuptools wheel if [[ "$REQ_FILE" == "requirements_cpu_only.txt" ]]; then echo "Installing CPU dependency profile..." python -m pip install --extra-index-url https://download.pytorch.org/whl/cpu -r "$REQ_FILE" else echo "Installing GPU dependency profile..." python -m pip install -r "$REQ_FILE" fi if [[ $WITH_NLP -eq 1 ]]; then echo "Installing optional NLP dependencies..." python -m pip install -r requirements_nlp_optional.txt echo "Attempting spaCy model install (ignored if unsupported on this Python)..." python -m spacy download en_core_web_sm || true fi echo "Done." echo "Activate with: source $VENV_DIR/bin/activate"