| | @echo off
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | setlocal enabledelayedexpansion
|
| |
|
| | echo ==========================================
|
| | echo Gemini Business2API Setup Script
|
| | echo ==========================================
|
| | echo.
|
| | |
| |
|
| | set GREEN=[92m
|
| | set RED=[91m
|
| | set YELLOW=[93m
|
| | set BLUE=[94m
|
| | set NC=[0m
|
| | |
| |
|
| | set "PRINT_SUCCESS=echo [SUCCESS]"
|
| | set "PRINT_ERROR=echo [ERROR]"
|
| | set "PRINT_INFO=echo [INFO]"
|
| | set "PRINT_STEP=echo [STEP]"
|
| | |
| |
|
| | where git >nul 2>nul
|
| | if %errorlevel% neq 0 (
|
| | echo [ERROR] Git is not installed. Please install git first.
|
| | exit /b 1
|
| | )
|
| | |
| |
|
| | echo [STEP] Step 1: Installing/Updating uv...
|
| |
|
| | where uv >nul 2>nul
|
| | if %errorlevel% neq 0 (
|
| | echo [INFO] uv not found, installing...
|
| |
|
| | pipx install uv 2>nul
|
| | if %errorlevel% neq 0 (
|
| | pip install --user uv 2>nul
|
| | if %errorlevel% neq 0 (
|
| |
|
| | curl -LsSf https://astral.sh/uv/install.bat | cmd
|
| | )
|
| | )
|
| | if %errorlevel% equ 0 (
|
| | echo [SUCCESS] uv installed successfully
|
| | ) else (
|
| | echo [ERROR] Failed to install uv
|
| | exit /b 1
|
| | )
|
| | ) else (
|
| | echo [INFO] Updating uv to latest version...
|
| | uv pip install --upgrade uv
|
| | echo [SUCCESS] uv updated
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 2: Ensuring Python 3.11 is available...
|
| | uv python list | findstr /C:"3.11" >nul
|
| | if %errorlevel% neq 0 (
|
| | echo [INFO] Python 3.11 not found, installing...
|
| | uv python install 3.11
|
| | if %errorlevel% neq 0 (
|
| | echo [ERROR] Failed to install Python 3.11
|
| | exit /b 1
|
| | )
|
| | echo [SUCCESS] Python 3.11 installed
|
| | ) else (
|
| | echo [SUCCESS] Python 3.11 is already available
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 3: Syncing code from repository...
|
| | echo [INFO] Fetching latest changes...
|
| | git fetch origin
|
| |
|
| | echo [INFO] Pulling latest code...
|
| | git pull origin main 2>nul || git pull origin master 2>nul
|
| | if %errorlevel% equ 0 (
|
| | echo [SUCCESS] Code synchronized successfully
|
| | ) else (
|
| | echo [INFO] No remote changes to pull
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 4: Checking configuration...
|
| | if exist .env (
|
| | echo [INFO] .env file exists
|
| | ) else (
|
| | if exist .env.example (
|
| | copy .env.example .env >nul
|
| | echo [SUCCESS] .env file created from .env.example
|
| | echo [INFO] Please edit .env and configure your ADMIN_KEY
|
| | ) else (
|
| | echo [ERROR] .env.example not found
|
| | exit /b 1
|
| | )
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 5: Setting up Python environment...
|
| | if exist .venv (
|
| | echo [INFO] Virtual environment already exists
|
| | ) else (
|
| | echo [INFO] Creating virtual environment with Python 3.11...
|
| | uv venv --python 3.11 .venv
|
| | if %errorlevel% neq 0 (
|
| | echo [ERROR] Failed to create virtual environment
|
| | exit /b 1
|
| | )
|
| | echo [SUCCESS] Virtual environment created
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 6: Installing Python dependencies...
|
| | echo [INFO] Using uv to install dependencies (this may take a moment)...
|
| | .venv\Scripts\python.exe -m pip install --upgrade pip --quiet
|
| | uv pip install -r requirements.txt
|
| | if %errorlevel% neq 0 (
|
| | echo [ERROR] Failed to install Python dependencies
|
| | exit /b 1
|
| | )
|
| | echo [SUCCESS] Python dependencies installed
|
| | echo.
|
| | |
| |
|
| | echo [STEP] Step 7: Setting up frontend...
|
| | if exist frontend (
|
| | cd frontend
|
| | |
| |
|
| | where npm >nul 2>nul
|
| | if %errorlevel% equ 0 (
|
| | echo [INFO] Installing dependencies...
|
| | npm install
|
| |
|
| | echo [INFO] Building frontend...
|
| | npm run build
|
| | echo [SUCCESS] Frontend built successfully
|
| | ) else (
|
| | echo [ERROR] npm is not installed. Please install Node.js and npm first.
|
| | cd ..
|
| | exit /b 1
|
| | )
|
| |
|
| | cd ..
|
| | ) else (
|
| | echo [ERROR] Frontend directory not found. Are you in the project root?
|
| | exit /b 1
|
| | )
|
| | echo.
|
| | |
| |
|
| | echo ==========================================
|
| | echo [SUCCESS] Setup completed successfully!
|
| | echo ==========================================
|
| | echo.
|
| |
|
| | if exist .env (
|
| | echo [INFO] Next steps:
|
| | echo.
|
| | echo 1. Edit .env file if needed:
|
| | echo notepad .env
|
| | echo.
|
| | echo 2. Start the service:
|
| | echo .venv\Scripts\python.exe main.py
|
| | echo.
|
| | echo 3. Access the admin panel:
|
| | echo http://localhost:7860/
|
| | echo.
|
| | echo [INFO] To activate virtual environment later, run:
|
| | echo .venv\Scripts\activate.bat
|
| | )
|
| | echo.
|
| |
|
| | endlocal
|
| |
|