feat: auto-run setup when virtual environment is missing
- Update run_gemini.sh to automatically run setup.sh if venv doesn't exist - Update run_gemini.bat to automatically run setup.bat if venv doesn't exist - Remove fallback to system Python - always use venv for consistency - Provide clear error messages if setup fails This ensures users don't see "ModuleNotFoundError" - instead the server will automatically set up dependencies on first run. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,20 +8,27 @@ REM Change to script directory to ensure proper working directory
|
||||
cd /d "%SCRIPT_DIR%"
|
||||
|
||||
REM Check if virtual environment exists
|
||||
if exist "%SCRIPT_DIR%venv\Scripts\activate.bat" (
|
||||
REM Activate the virtual environment
|
||||
call "%SCRIPT_DIR%venv\Scripts\activate.bat"
|
||||
python "%SCRIPT_DIR%server.py"
|
||||
) else (
|
||||
REM Try to use python directly if no venv
|
||||
echo Warning: Virtual environment not found at %SCRIPT_DIR%venv >&2
|
||||
echo Attempting to run with system Python... >&2
|
||||
python "%SCRIPT_DIR%server.py"
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to run server. Please ensure Python is installed and dependencies are available. >&2
|
||||
echo Run: python -m venv venv >&2
|
||||
echo Then: venv\Scripts\activate >&2
|
||||
echo Then: pip install -r requirements.txt >&2
|
||||
if not exist "%SCRIPT_DIR%venv\" (
|
||||
echo Virtual environment not found. Running setup... >&2
|
||||
|
||||
REM Check if setup.bat exists
|
||||
if exist "%SCRIPT_DIR%setup.bat" (
|
||||
REM Run setup script
|
||||
call "%SCRIPT_DIR%setup.bat" >&2
|
||||
|
||||
REM Check if setup was successful
|
||||
if errorlevel 1 (
|
||||
echo Setup failed. Please run setup.bat manually to see the error. >&2
|
||||
exit /b 1
|
||||
)
|
||||
) else (
|
||||
echo Error: setup.bat not found. Please ensure you have the complete repository. >&2
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM Activate virtual environment
|
||||
call "%SCRIPT_DIR%venv\Scripts\activate.bat"
|
||||
|
||||
REM Run the server
|
||||
python "%SCRIPT_DIR%server.py"
|
||||
@@ -4,19 +4,34 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Check if virtual environment exists
|
||||
if [ -d "$SCRIPT_DIR/venv" ]; then
|
||||
# Activate virtual environment
|
||||
source "$SCRIPT_DIR/venv/bin/activate"
|
||||
PYTHON_EXEC="python"
|
||||
else
|
||||
# Fallback to system Python if venv doesn't exist
|
||||
echo "Warning: Virtual environment not found at $SCRIPT_DIR/venv" >&2
|
||||
echo "Using system Python. Make sure dependencies are installed." >&2
|
||||
PYTHON_EXEC="python3"
|
||||
if [ ! -d "$SCRIPT_DIR/venv" ]; then
|
||||
echo "Virtual environment not found. Running setup..." >&2
|
||||
|
||||
# Check if setup.sh exists and is executable
|
||||
if [ -f "$SCRIPT_DIR/setup.sh" ]; then
|
||||
if [ ! -x "$SCRIPT_DIR/setup.sh" ]; then
|
||||
chmod +x "$SCRIPT_DIR/setup.sh"
|
||||
fi
|
||||
|
||||
# Run setup script
|
||||
"$SCRIPT_DIR/setup.sh" >&2
|
||||
|
||||
# Check if setup was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Setup failed. Please run setup.sh manually to see the error." >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: setup.sh not found. Please ensure you have the complete repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Activate virtual environment
|
||||
source "$SCRIPT_DIR/venv/bin/activate"
|
||||
|
||||
# Change to script directory to ensure proper working directory
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# Run the server
|
||||
exec "$PYTHON_EXEC" "$SCRIPT_DIR/server.py"
|
||||
exec python "$SCRIPT_DIR/server.py"
|
||||
Reference in New Issue
Block a user