12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env bash
- # install.sh – minimal Conda bootstrap with ~/.bashrc check
- set -e
-
- ENV=kg-env # must match your environment.yml
- YAML=kg_env.yaml # assumed to be in the current dir
-
- # ── 1. try to load an existing conda from ~/.bashrc ──────────────────────
- [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" || true
-
- # ── 2. ensure conda exists ───────────────────────────────────────────────
- if ! command -v conda &>/dev/null; then
- echo "[install.sh] Conda not found → installing Miniconda."
- curl -fsSL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh
- bash miniconda.sh -b -p "$HOME/miniconda3"
- rm miniconda.sh
- source "$HOME/miniconda3/etc/profile.d/conda.sh"
- conda init bash >/dev/null # so future shells have it
- else
- # conda exists; load its helper for this shell
- source "$(conda info --base)/etc/profile.d/conda.sh"
- fi
-
- # ── 3. create or update the project env ──────────────────────────────────
- conda env create -n "$ENV" -f "$YAML" \
- || conda env update -n "$ENV" -f "$YAML" --prune
-
- echo "✔ Done. Activate with: conda activate $ENV"
|