Skip to content

Commit 9445549

Browse files
author
Lincoln Stein
committed
add back --windowed to macOS build; post-process to launch terminal
1 parent 18bca77 commit 9445549

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

INSTALL/pyinstaller/make_pyinstaller_image.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fi
3434

3535
# Set PyInstaller mode based on torch variant and platform
3636
if [[ "$MACOS_APP" == true ]]; then
37-
PYINSTALLER_MODE=""
37+
PYINSTALLER_MODE="--windowed"
3838
elif [[ "$TORCH_VARIANT" == cpu ]]; then
3939
PYINSTALLER_MODE="--onefile"
4040
else
@@ -129,13 +129,26 @@ df -h
129129
# After PyInstaller
130130
rm -rf build/ # Remove PyInstaller temp files
131131

132-
# Remove unpacked directory if building macOS app bundle
132+
# Post-process macOS .app bundle to launch in Terminal
133133
if [[ "$MACOS_APP" == true ]]; then
134-
if [ -d dist/photomap ]; then
135-
rm -rf dist/photomap
136-
fi
134+
APP_BUNDLE="dist/photomap.app"
135+
MACOS_DIR="$APP_BUNDLE/Contents/MacOS"
136+
BIN_NAME="photomap"
137+
138+
# Create a launcher script
139+
LAUNCHER="$MACOS_DIR/run_in_terminal.sh"
140+
cat > "$LAUNCHER" <<EOF
141+
#!/bin/bash
142+
exec osascript -e 'tell application "Terminal" to do script "'"$MACOS_DIR/$BIN_NAME"'"'
143+
EOF
144+
chmod +x "$LAUNCHER"
145+
146+
# Update Info.plist to use the launcher script
147+
PLIST="$APP_BUNDLE/Contents/Info.plist"
148+
/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable run_in_terminal.sh" "$PLIST"
149+
137150
echo "✅ macOS app bundle created: dist/photomap.app"
138-
echo "Users can double-click photomap.app to launch PhotoMap"
151+
echo "Users can double-click photomap.app to launch PhotoMap in Terminal"
139152
else
140153
echo "✅ Executable created in dist/ directory"
141154
fi

0 commit comments

Comments
 (0)