#!/usr/bin/env bash set -euo pipefail # Build a macOS standalone executable and package into a DMG. # NOTE: This script must be run on macOS. It cannot produce a mac DMG on Windows. python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt pyinstaller pip install playwright .venv/bin/playwright install chromium # Create one-file executable pyinstaller --onefile --name ADM_PURCHASING_TOOLS main.py # Create a minimal .app bundle then DMG APP_NAME=ADM_PURCHASING_TOOLS DIST_DIR=dist EXEC_PATH="$DIST_DIR/$APP_NAME" if [ ! -f "$EXEC_PATH" ]; then echo "Build failed: $EXEC_PATH not found" exit 1 fi rm -rf "$APP_NAME.app" mkdir -p "$APP_NAME.app/Contents/MacOS" cp "$EXEC_PATH" "$APP_NAME.app/Contents/MacOS/$APP_NAME" cat > "$APP_NAME.app/Contents/Info.plist" < CFBundleName$APP_NAMECFBundleExecutable$APP_NAME EOF DMG_NAME="$APP_NAME.dmg" if command -v hdiutil >/dev/null 2>&1; then hdiutil create -volname "$APP_NAME" -srcfolder "$APP_NAME.app" -ov -format UDZO "$DMG_NAME" echo "Created $DMG_NAME" else echo "hdiutil not found — built app bundle at $APP_NAME.app. Create a DMG on macOS with hdiutil." fi