2025-08-19 21:56:49 +02:00

54 lines
1.6 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
REM Set file paths
set ROOT_DIR=%~dp0..
set CONFIG_FILE=%ROOT_DIR%\config.json
set REQUIREMENTS=%ROOT_DIR%\requirements.txt
set ENV_FILE=%ROOT_DIR%\.env
REM Check if .env file exists
if not exist "%ENV_FILE%" (
echo [ERROR] .env file not found. Please copy .env.example to .env and configure it.
exit /b 1
)
REM Extract config.json fields using PowerShell
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty architecture"') do set ARCHITECTURE=%%i
REM Extract python path from .env file
for /f "usebackq tokens=2 delims==" %%i in (`findstr "PYTHON_PATH" "%ENV_FILE%"`) do set PYTHON_EXEC=%%i
REM Construct python executable path
set ENV_NAME=WINenv_%ARCHITECTURE%
set ENV_PATH=%ROOT_DIR%\%ENV_NAME%
if not exist "%PYTHON_EXEC%" (
echo [ERROR] Python introuvable à: %PYTHON_EXEC%
echo Veuillez vérifier votre .env ou le dossier d'installation.
exit /b 1
)
REM Show config info
echo [INFO] Configuration :
echo Python: %PYTHON_EXEC%
echo Env: %ENV_NAME%
REM Check if virtual environment exists
if not exist "%ENV_PATH%\Scripts" (
echo [INFO] Environnement virtuel introuvable, création...
"%PYTHON_EXEC%" -m venv "%ENV_PATH%"
echo [INFO] Installation des dépendances...
"%ENV_PATH%\Scripts\python" -m pip install --upgrade pip
"%ENV_PATH%\Scripts\pip" install -r "%REQUIREMENTS%"
) else (
echo [INFO] Environnement virtuel trouvé.
)
REM Activate and launch VS Code
echo [INFO] Lancement de VS Code...
call "%ENV_PATH%/Scripts/activate.bat"
start code "%ROOT_DIR%"
exit /b 0