diff --git a/.gitignore b/.gitignore index b757d55..8d0b5f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ __pycache__/ *.pyc .env +.venv/ +bin/ *.egg-info/ dist/ node_modules/ diff --git a/README.md b/README.md index b733e2a..91ade96 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ chmod +x install.sh && ./install.sh | Tool | Required? | Install | |------|-----------|---------| -| Python 3.10+ | ✅ Required | `sudo apt install python3 python3-pip` | +| Python 3.10+ | ✅ Required | Auto-installed via `uv` by `install.sh` | | Node.js 18+ | ⚠ For opencode | `curl -fsSL https://deb.nodesource.com/setup_20.x \| sudo bash - && sudo apt install -y nodejs` | | opencode | ⚠ For code tasks | `npm install -g @opencode/cli` | | Hermes Agent | ⚠ For memory/scheduling | `curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh \| bash` | diff --git a/install.sh b/install.sh index de32e91..47bec66 100755 --- a/install.sh +++ b/install.sh @@ -17,19 +17,41 @@ echo "Detected OS: $OS" if command -v python3 &>/dev/null; then echo "Python: $(python3 --version)" else - echo "ERROR: Python 3.10+ required. Install via: sudo apt install python3 python3-pip" + echo "ERROR: Python 3.10+ required. Install via: sudo apt install python3" exit 1 fi -# Check pip -if ! command -v pip3 &>/dev/null; then - echo "Installing pip..." - python3 -m ensurepip --upgrade +# Install uv into bin/ if not present +BIN_DIR="bin" +UV="$BIN_DIR/uv" +if [ -x "$UV" ]; then + echo "uv: $($UV --version)" +else + echo "Installing uv to $BIN_DIR/..." + mkdir -p "$BIN_DIR" + curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$PWD/$BIN_DIR" sh + if [ ! -x "$UV" ]; then + echo "ERROR: uv installation failed. Install manually: curl -LsSf https://astral.sh/uv/install.sh | sh" + exit 1 + fi + echo "uv: $($UV --version)" + # Remove shell helper scripts — we reference bin/uv directly + rm -f "$BIN_DIR/env" "$BIN_DIR/env.fish" fi -# Install Python deps +# Create virtual environment +VENV_DIR=".venv" +if [ -d "$VENV_DIR" ]; then + echo "Virtual environment already exists at $VENV_DIR/" +else + echo "Creating virtual environment..." + "$UV" venv "$VENV_DIR" --python 3.12 + echo "Created $VENV_DIR/" +fi + +# Install Python deps into venv echo "Installing Python dependencies..." -pip3 install -r requirements.txt --quiet +"$UV" pip install --python "$VENV_DIR/bin/python3" -r requirements.txt --quiet # Check Node.js (for opencode) if command -v node &>/dev/null; then diff --git a/scheduler/scheduler.py b/scheduler/scheduler.py index 0d9d217..963935d 100644 --- a/scheduler/scheduler.py +++ b/scheduler/scheduler.py @@ -151,7 +151,7 @@ class CronScheduler: from apscheduler.schedulers.background import BackgroundScheduler as BS from apscheduler.triggers.cron import CronTrigger as CT except ImportError: - print("Install APScheduler: pip install apscheduler") + print("APScheduler not found. Run ./install.sh to install dependencies.") return self._scheduler = BS() self._reload_jobs() diff --git a/start.sh b/start.sh index 8dea07b..80d5be1 100755 --- a/start.sh +++ b/start.sh @@ -10,18 +10,31 @@ if [ ! -f server.py ]; then exit 1 fi -# Check dependencies -pip3 install -r requirements.txt --quiet 2>/dev/null +# Check virtual environment +VENV_DIR=".venv" +if [ ! -d "$VENV_DIR" ]; then + echo "Virtual environment not found. Run ./install.sh first." + exit 1 +fi + +# Use venv Python directly (no shell activation needed) +PYTHON="$VENV_DIR/bin/python3" + +# Ensure deps are up to date +UV="bin/uv" +if [ -x "$UV" ]; then + "$UV" pip install --python "$PYTHON" -r requirements.txt --quiet +else + "$PYTHON" -m pip install -r requirements.txt --quiet +fi # Get port from settings or default PORT=8080 -if command -v python3 &>/dev/null; then - PORT=$(python3 -c "import json; f=open('data/settings.json'); d=json.load(f); print(d.get('dashboard',{}).get('port',8080)); f.close()" 2>/dev/null || echo "8080") -fi +PORT=$("$PYTHON" -c "import json; f=open('data/settings.json'); d=json.load(f); print(d.get('dashboard',{}).get('port',8080)); f.close()" 2>/dev/null || echo "8080") echo "Dashboard: http://127.0.0.1:${PORT}" echo "Press Ctrl+C to stop" echo "" -# Start server -python3 server.py --port "${PORT}" +# Start server using venv Python +"$PYTHON" server.py --port "${PORT}"