#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT_DIR" PYTHON_BIN="${PYTHON_BIN:-./.venv/bin/python}" if [[ ! -x "$PYTHON_BIN" ]]; then echo "Python executable not found: $PYTHON_BIN" >&2 exit 1 fi if [[ -n "${PYINSTALLER_BIN:-}" ]]; then if [[ ! -x "$PYINSTALLER_BIN" ]]; then echo "PyInstaller executable not found: $PYINSTALLER_BIN" >&2 exit 1 fi PYINSTALLER_CMD=("$PYINSTALLER_BIN") else if ! "$PYTHON_BIN" -c "import PyInstaller" >/dev/null 2>&1; then echo "PyInstaller is not installed in: $PYTHON_BIN" >&2 echo "Install it with: uv pip install --python ./.venv/bin/python pyinstaller" >&2 exit 1 fi PYINSTALLER_CMD=("$PYTHON_BIN" -m PyInstaller) fi VERSION="$("$PYTHON_BIN" -c "from pathlib import Path; import tomllib; print(tomllib.loads(Path('pyproject.toml').read_text(encoding='utf-8'))['project']['version'])")" OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" ARCH_NAME="$(uname -m)" VERSIONED_OUTPUT="dist/mlog-tool-qt-v${VERSION}-${OS_NAME}-${ARCH_NAME}" echo "Building Qt executable with ${PYINSTALLER_CMD[*]}" QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}" "${PYINSTALLER_CMD[@]}" --noconfirm --clean mlog_tool_qt.spec cp dist/mlog-tool-qt "$VERSIONED_OUTPUT" echo echo "Build finished:" echo " dist/mlog-tool-qt" echo " $VERSIONED_OUTPUT"