Skip to content

Commit

Permalink
Improve .app startup time by switching pyinstaller from onefile to on…
Browse files Browse the repository at this point in the history
…edir

I was under the impression that because MacOS applications are distributed as single .app files, you have to use the pyinstaller `onefile` option when building them. Because of the large size of the application's dependencies, opening the it would take forever as they are all unzipped. It turns out that there is no such requirement, and that if you are willing to accept a larger application, you can get much faster startup times by using `onedir`. The application is still a single .app file, but it opens much faster because the dependencies aren't zipped into a single file internally.
  • Loading branch information
reilleya committed Jan 10, 2025
1 parent ce31ead commit de56264
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pyinstaller/macOneFile.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- mode: python -*-

# Run with `pyinstaller --windowed --onefile`
# Run with `pyinstaller --windowed --onedir`

from uilib.fileIO import appVersionStr

Expand All @@ -17,23 +17,29 @@ a = Analysis(['../main.py'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
noarchive=False,
target_arch=['x86_64', 'arm64'])
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
exclude_binaries=True,
name='openMotor',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False )
app = BUNDLE(exe,
console=False)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='openMotor')
app = BUNDLE(coll,
name='openMotor.app',
icon='../resources/oMIconCycles.icns',
version=appVersionStr,
Expand Down

0 comments on commit de56264

Please sign in to comment.