@echo off setlocal rem Build a standalone Catalogizer.exe: double-click this file in Explorer. rem Any arguments are passed to scripts\build_exe.py (--onedir, --console, --cli). rem --setup create .venv and install PySide6 + pymupdf + PyInstaller first set "MODULE_ROOT=%~dp0." set "VENV_PYTHON=%MODULE_ROOT%\.venv\Scripts\python.exe" set "BUILD_SCRIPT=%MODULE_ROOT%\scripts\build_exe.py" set "PACKED_EXE=%MODULE_ROOT%\dist\Catalogizer.exe" set "EXE_NAME=Catalogizer.exe" set "PACKAGES=PySide6 pymupdf pyinstaller" set "BUILD_ARGS=%*" if /i "%~1"=="--setup" ( set "BUILD_ARGS=" goto setup ) if exist "%VENV_PYTHON%" goto have_python echo Local .venv is missing. echo Starting the one-time build environment setup. echo. :setup echo Preparing the build environment in .venv - this takes a few minutes. echo. if not exist "%VENV_PYTHON%" ( python -m venv "%MODULE_ROOT%\.venv" if errorlevel 1 ( echo Failed to create .venv. Is Python installed and in PATH? pause exit /b 1 ) ) "%VENV_PYTHON%" -m pip install --upgrade pip "%VENV_PYTHON%" -m pip install %PACKAGES% if errorlevel 1 ( echo Failed to install %PACKAGES%. pause exit /b 1 ) echo. :have_python if not exist "%VENV_PYTHON%" ( echo Build environment is missing: "%VENV_PYTHON%" echo Create it with: BUILD_EXE.bat --setup pause exit /b 1 ) rem A running build keeps its own file locked and PyInstaller fails halfway. "%SystemRoot%\System32\tasklist.exe" /FI "IMAGENAME eq %EXE_NAME%" 2>nul | "%SystemRoot%\System32\find.exe" /I "%EXE_NAME%" >nul if not errorlevel 1 ( echo %EXE_NAME% is running and cannot be overwritten. echo Close the application and start the build again. echo. pause exit /b 1 ) "%VENV_PYTHON%" "%BUILD_SCRIPT%" %BUILD_ARGS% if errorlevel 1 ( echo. echo Build failed. See README.md, section about the exe. pause exit /b 1 ) rem Self-check: the packed build has no console to show a traceback. if exist "%PACKED_EXE%" ( "%PACKED_EXE%" --check if errorlevel 1 ( echo. echo The build starts but the main window is broken. pause exit /b 1 ) ) echo. echo Done. Start it with CATALOG.bat or run dist\%EXE_NAME% directly. pause exit /b 0