@echo off
setlocal
cd /d "%~dp0"
set APP_FILE=beanalyzer_ultrapro.py
set VENV_DIR=.venv
if not exist "%APP_FILE%" (
  echo %APP_FILE% not found. Put this launcher in the project folder.
  pause
  exit /b 1
)
where py >nul 2>nul
if %errorlevel%==0 (
  set PYTHON_CMD=py -3.12
  py -3.12 --version >nul 2>nul
  if errorlevel 1 set PYTHON_CMD=py -3
) else (
  set PYTHON_CMD=python
)
if not exist "%VENV_DIR%" (
  %PYTHON_CMD% -m venv "%VENV_DIR%"
  if errorlevel 1 (
    echo Could not create venv. Install Python 3.12.
    pause
    exit /b 1
  )
)
call "%VENV_DIR%\Scripts\activate.bat"
python --version
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
if errorlevel 1 (
  echo Requirements installation failed. Python 3.12 is recommended.
  pause
  exit /b 1
)
python "%APP_FILE%"
pause
