Fix Install Scripts

This commit is contained in:
2026-01-07 20:07:38 +00:00
parent e6ed6fcfac
commit a21cd50e9c
3 changed files with 27 additions and 5 deletions

View File

@@ -14,12 +14,18 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
# Deactivate any existing virtual environment to avoid conflicts
if [ -n "$VIRTUAL_ENV" ]; then
deactivate 2>/dev/null || true
fi
# Source ArduPilot environment # Source ArduPilot environment
if [ -f "$HOME/.ardupilot_env" ]; then if [ -f "$HOME/.ardupilot_env" ]; then
source "$HOME/.ardupilot_env" source "$HOME/.ardupilot_env"
fi fi
# Activate ArduPilot venv (has empy and other dependencies) # Activate ArduPilot venv (has empy and other dependencies)
# This MUST be the active venv for sim_vehicle.py to work
if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then
source "$HOME/venv-ardupilot/bin/activate" source "$HOME/venv-ardupilot/bin/activate"
fi fi
@@ -36,9 +42,13 @@ if ! command -v sim_vehicle.py &> /dev/null; then
exit 1 exit 1
fi fi
# Activate virtual environment if exists # Verify correct Python environment (ArduPilot venv should have empy)
if [ -f "$PROJECT_DIR/venv/bin/activate" ]; then if ! python3 -c "import em" 2>/dev/null; then
source "$PROJECT_DIR/venv/bin/activate" echo "[WARN] empy not found in current Python environment"
echo "[INFO] Attempting to use ArduPilot venv..."
if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then
source "$HOME/venv-ardupilot/bin/activate"
fi
fi fi
# Start SITL in background # Start SITL in background

View File

@@ -129,11 +129,17 @@ if [ -f "$HOME/.ardupilot_env" ]; then
echo "[OK] ArduPilot environment" echo "[OK] ArduPilot environment"
fi fi
# Deactivate any existing venv to avoid conflicts
if [ -n "$VIRTUAL_ENV" ]; then
deactivate 2>/dev/null || true
fi
# Activate ArduPilot venv (has empy and other dependencies) # Activate ArduPilot venv (has empy and other dependencies)
# This is preferred over project venv for ArduPilot compatibility
if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then
source "$HOME/venv-ardupilot/bin/activate" source "$HOME/venv-ardupilot/bin/activate"
echo "[OK] ArduPilot venv" echo "[OK] ArduPilot venv"
# Fallback to project venv # Fallback to project venv only if ArduPilot not installed
elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then
source "$SCRIPT_DIR/venv/bin/activate" source "$SCRIPT_DIR/venv/bin/activate"
echo "[OK] Python venv activated" echo "[OK] Python venv activated"

View File

@@ -183,11 +183,17 @@ if [ -f "$HOME/.ardupilot_env" ]; then
echo "[OK] ArduPilot environment" echo "[OK] ArduPilot environment"
fi fi
# Deactivate any existing venv to avoid conflicts
if [ -n "$VIRTUAL_ENV" ]; then
deactivate 2>/dev/null || true
fi
# Activate ArduPilot venv (has empy and other dependencies) # Activate ArduPilot venv (has empy and other dependencies)
# This is preferred over project venv for ArduPilot compatibility
if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then if [ -f "$HOME/venv-ardupilot/bin/activate" ]; then
source "$HOME/venv-ardupilot/bin/activate" source "$HOME/venv-ardupilot/bin/activate"
echo "[OK] ArduPilot venv" echo "[OK] ArduPilot venv"
# Fallback to project venv # Fallback to project venv only if ArduPilot not installed
elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then elif [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then
source "$SCRIPT_DIR/venv/bin/activate" source "$SCRIPT_DIR/venv/bin/activate"
echo "[OK] Python venv" echo "[OK] Python venv"