Skip to content

Commit 2dd3c96

Browse files
committed
darwin: strip embedded Python.app from Python.framework
python-build-standalone bakes a standalone launcher Python.app into Python.framework/Versions/<ver>/Resources/. Its Mach-O has a hardcoded load command: /Users/runner/work/python-build/python-build/darwin/install/macOS/ macosx/python-3.X.Y/Python.framework/Versions/X.Y/Python — literally the CI runner's build path. DYLD can't resolve it anywhere else, so any attempt to launch the Python.app fails with "Library missing". macOS LaunchServices scans nested .app bundles inside a .app's Contents/Frameworks/ on launch (`flet debug macos`, `flet run`, or just opening the built .app) and reliably triggers a flood of "Python quit unexpectedly" crash report dialogs. The launcher is only useful for standalone interpreter sessions (the GUI Python.app you launch from /Applications); libdart_bridge dlopens the framework's main binary directly and ignores it. Strip it after extraction. Existing both in 3.12 and 3.14 tarballs from flet-dev/python-build — the previous serious_python (pub.dev 1.0.x) packaging path apparently didn't expose it to LaunchServices, which is why it never surfaced before the dart-bridge rewrite started routing Python.xcframework through CocoaPods' vendored_frameworks into Contents/Frameworks/.
1 parent fdb3bf7 commit 2dd3c96

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/serious_python_darwin/darwin/prepare_macos.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ if [ ! -d "$dist" ]; then
2929
mkdir -p "$dist"
3030
tar -xzf "$python_macos_dist_path" -C "$dist"
3131
mv "$dist/python-stdlib" "$dist/stdlib"
32+
33+
# python-build-standalone bakes a standalone launcher Python.app into
34+
# Python.framework/Versions/<ver>/Resources/. Its Mach-O has a hardcoded
35+
# load command pointing at the CI runner's build path
36+
# (/Users/runner/work/python-build/.../Python.framework/Versions/X.Y/Python),
37+
# so DYLD can't resolve it on any other machine. When the host .app is
38+
# built, macOS LaunchServices scans nested .app bundles and tries to
39+
# launch this Python.app — every scan produces a "Python quit
40+
# unexpectedly" crash dialog. We don't need this launcher for embedded
41+
# use; libdart_bridge dlopens Python.framework's main binary directly.
42+
find "$dist/xcframeworks" -type d -name 'Python.app' -prune -exec rm -rf {} +
3243
fi
3344

3445
# ---- flet-dev/dart-bridge (xcframework, same archive for macOS + iOS) -----

0 commit comments

Comments
 (0)