@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 REM Extract config.json fields using PowerShell for /f "delims=" %%i in ('powershell -NoProfile -Command ^ "Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty python_version"') do set PYTHON_VERSION=%%i for /f "delims=" %%i in ('powershell -NoProfile -Command ^ "Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty architecture"') do set ARCHITECTURE=%%i for /f "delims=" %%i in ('powershell -NoProfile -Command ^ "Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty python_path"') 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 config.json 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