47 lines
1.5 KiB
Batchfile
47 lines
1.5 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM Set file paths
|
|
set CONFIG_FILE=%~dp0config.json
|
|
set REQUIREMENTS=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
|
|
|
|
REM Construct python executable path
|
|
set PYTHON_EXEC=C:\Logiciels\Python\%ARCHITECTURE%\%PYTHON_VERSION%\python.exe
|
|
set ENV_NAME=WINenv_%ARCHITECTURE%
|
|
set ENV_PATH=%~dp0%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\activate.bat" (
|
|
echo [INFO] Environnement virtuel introuvable, création...
|
|
"%PYTHON_EXEC%" -m venv "%ENV_NAME%"
|
|
echo [INFO] Installation des dépendances...
|
|
"%ENV_PATH%\Scripts\pip" install --upgrade pip
|
|
"%ENV_PATH%\Scripts\pip" install -r "%REQUIREMENTS%"
|
|
) else (
|
|
echo [INFO] Environnement virtuel trouvé.
|
|
)
|
|
|
|
REM Activate and launch VS Code
|
|
call "%ENV_PATH%\Scripts\activate.bat"
|
|
echo [INFO] Lancement de VS Code...
|
|
start code "%~dp0"
|
|
|
|
exit /b 0
|