#!/bin/bash # Build a standalone Catalogizer.app on macOS: double-click this file in Finder. # Any arguments are passed to scripts/build_exe.py (--console, --cli). # --setup create .venv and install PySide6 + pymupdf + PyInstaller first # # PyInstaller cannot cross-compile: run this on the Mac itself. set -u MODULE_ROOT="$(cd "$(dirname "$0")" && pwd)" VENV_PYTHON="$MODULE_ROOT/.venv/bin/python3" BUILD_SCRIPT="$MODULE_ROOT/scripts/build_exe.py" PACKED_APP="$MODULE_ROOT/dist/Catalogizer.app" PACKAGES="PySide6 pymupdf pyinstaller" setup() { echo "Preparing the build environment in .venv - this takes a few minutes." if [ ! -x "$VENV_PYTHON" ]; then python3 -m venv "$MODULE_ROOT/.venv" || { echo "Failed to create .venv. Is python3 installed?"; exit 1; } fi "$VENV_PYTHON" -m pip install --upgrade pip "$VENV_PYTHON" -m pip install $PACKAGES || { echo "Failed to install $PACKAGES."; exit 1; } } if [ "${1:-}" = "--setup" ]; then setup shift elif [ ! -x "$VENV_PYTHON" ]; then echo "Local .venv is missing. Starting the one-time setup." setup fi # A running build keeps its own files locked and PyInstaller fails halfway. if pgrep -x Catalogizer >/dev/null 2>&1; then echo "Catalogizer is running and cannot be overwritten." echo "Quit the application and start the build again." exit 1 fi "$VENV_PYTHON" "$BUILD_SCRIPT" "$@" || { echo; echo "Build failed. See README.md, section about the app."; exit 1; } # Self-check: the packed build has no console to show a traceback. if [ -d "$PACKED_APP" ]; then "$PACKED_APP/Contents/MacOS/Catalogizer" --check || { echo; echo "The build starts but the main window is broken."; exit 1; } fi echo echo "Done. Start it with CATALOG.command or open dist/Catalogizer.app."