Skip to content

Use onedir PyInstaller bundles for faster macOS launch#2765

Open
Collinw24 wants to merge 1 commit into
pyfa-org:masterfrom
Collinw24:macos-onedir-startup-zip-symlinks
Open

Use onedir PyInstaller bundles for faster macOS launch#2765
Collinw24 wants to merge 1 commit into
pyfa-org:masterfrom
Collinw24:macos-onedir-startup-zip-symlinks

Conversation

@Collinw24
Copy link
Copy Markdown

Summary

This changes the macOS PyInstaller bundle from onefile to onedir.

The current onefile app has a large amount of work before pyfa itself starts. On macOS that makes the packaged app look like it is hanging for a long time before any window appears. With onedir, the bundled files live inside the app bundle instead of being unpacked into a temp directory on every launch.

This keeps the output as pyfa.app and does not change pyfa startup/runtime code.

The packaging script now uses zip -y so macOS bundle symlinks are stored as symlinks in the release archive instead of being followed and duplicated.

Refs #1605.

Measurements

Measured on:

  • Apple M3 Max
  • macOS 26.3.1
  • Python 3.11.9
  • PyInstaller 6.2.0, matching scripts/osx-setup.sh
  • local package builds from scripts/osx-package.sh
Build Package format First window
upstream/master at a46ad2b81 onefile app bundle no window within the 60s timeout in 3/3 measured runs
this branch onedir app bundle 1.54s / 1.59s / 1.68s, median 1.59s

I also used a temporary instrumented build to split out the pre-Python time. That instrumentation is not included in this PR. With the onedir bundle, the median timing was:

  • first pyfa bytecode: 0.158s
  • MainFrame.Show(): 1.48s
  • first idle: 1.66s

Tradeoff

The installed app bundle is larger and contains more files, but preserving symlinks in the zip keeps the release archive close to the current onefile size:

Build App bundle Zip Bundle contents
onefile baseline ~80M ~81M 4 files
onedir ~251M ~96M 5,062 files + 94 symlinks

QA

  • python scripts/compile_lang.py
  • python db_update.py
  • PYFA_VERSION=qa-pyi62-onedir-symlinkzip bash scripts/osx-package.sh using PyInstaller 6.2.0
  • extracted the script-built zip with /usr/bin/unzip and verified it preserved 94 symlinks
  • codesign --verify --deep --strict --verbose=2 on the extracted app
  • extracted-app launch check with a 5s settle between relaunches: 1.64s / 1.65s / 1.65s / 1.71s / 1.99s, median 1.65s
  • git diff --check

Local pytest note: I did not treat pytest as the validation path for this packaging-only change. In this checkout, current local collection fails before tests run due existing test setup/import issues (saveddata.db path on normal run, then IPortUser import under TRAVIS=true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant