ADM-Purchasing-Tools / app /build_mac.sh
abdulsalam2121
Add automation bot with Flask and Playwright
5b29309
Raw
History Blame Contribute Delete
1.42 kB
#!/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" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict><key>CFBundleName</key><string>$APP_NAME</string><key>CFBundleExecutable</key><string>$APP_NAME</string></dict></plist>
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