File size: 2,070 Bytes
0109502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# One-time setup for macOS/Linux.
#
# Creates an isolated virtual environment INSIDE this project folder
# (.venv/) and installs the pipeline's dependencies into it. This never
# touches your system Python, any other project's packages, or anything
# outside this folder — deleting the project folder removes everything
# this script installed (except Gitleaks, which is a separate one-time
# system tool; see the message at the end).
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"

PYTHON_BIN="${PYTHON_BIN:-python3}"

if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
    echo "ERROR: $PYTHON_BIN not found. Install Python 3.10+ first: https://www.python.org/downloads/"
    exit 1
fi

echo "Using $($PYTHON_BIN --version)"

if [ ! -d ".venv" ]; then
    echo "Creating isolated virtual environment in .venv/ ..."
    "$PYTHON_BIN" -m venv .venv
else
    echo ".venv/ already exists — reusing it."
fi

# shellcheck disable=SC1091
source .venv/bin/activate

echo "Installing dependencies into .venv/ (this does not touch system Python) ..."
pip install --quiet --upgrade pip
pip install --quiet -r requirements.txt

if [ ! -f ".env" ]; then
    cp .env.example .env
    echo "Created .env from .env.example — edit it and fill in NIM_API_KEY, NIM_BASE_URL, NIM_MODEL."
else
    echo ".env already exists — leaving it alone."
fi

echo
echo "Checking for Gitleaks (required unless you deliberately set ALLOW_MISSING_GITLEAKS=1) ..."
if command -v gitleaks >/dev/null 2>&1; then
    echo "  Found: $(gitleaks version 2>&1 | head -n1)"
else
    echo "  NOT found. Install it (one-time, system-level, like installing any CLI tool):"
    echo "    macOS:  brew install gitleaks"
    echo "    Linux:  see https://github.com/gitleaks/gitleaks#installing"
    echo "  Until it's installed, real runs will refuse to start (fails closed by design)."
fi

echo
echo "Setup complete."
echo "Next: edit .env with your NIM credentials, then run scripts/run_daily.sh"