From 842c50bb6a711d6d1d6e354715f49d95675dfb1f Mon Sep 17 00:00:00 2001 From: jerick Date: Sun, 3 May 2026 23:55:01 -0400 Subject: [PATCH] venv fix --- install.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 5b7d10b..4ffcf9b 100644 --- a/install.sh +++ b/install.sh @@ -24,8 +24,12 @@ echo "Installing crypto-trader to $INSTALL_DIR ..." mkdir -p "$INSTALL_DIR" # ── 2. Copy project files ───────────────────────────────────────────────── -rsync -a --exclude='.git' --exclude='venv' --exclude='__pycache__' \ - "$SCRIPT_DIR/" "$INSTALL_DIR/" +# Skip if already running from the install directory +if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then + for item in *.py *.txt *.sh *.md .env.example systemd; do + [ -e "$SCRIPT_DIR/$item" ] && cp -r "$SCRIPT_DIR/$item" "$INSTALL_DIR/" + done +fi # ── 3. Create dedicated system user ────────────────────────────────────── if ! id -u "$SERVICE_USER" &>/dev/null; then @@ -45,13 +49,16 @@ if [ ! -f "$INSTALL_DIR/.env" ]; then fi # ── 5. Python virtual environment ───────────────────────────────────────── -if ! command -v python3 &>/dev/null; then - echo "Installing python3-venv ..." - apt-get install -y python3-venv python3-pip -fi +# python3 is pre-installed on Ubuntu but python3-venv is a separate package +# that is frequently absent — install it unconditionally (apt is idempotent) +echo "Ensuring python3-venv and pip are available..." +apt-get install -y python3-venv python3-pip if [ ! -d "$INSTALL_DIR/venv" ]; then - python3 -m venv "$INSTALL_DIR/venv" + python3 -m venv "$INSTALL_DIR/venv" || { + echo "ERROR: 'python3 -m venv' failed. Try: apt-get install python3-venv" + exit 1 + } fi "$INSTALL_DIR/venv/bin/pip" install --upgrade pip -q "$INSTALL_DIR/venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt" -q