Skip to content

Commit 1d55ddf

Browse files
committed
Improve .app startup time by switching pyinstaller from onefile to onedir
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. The application was slow to open because it had to unzip its huge dependencies on every startup. 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.
1 parent ce31ead commit 1d55ddf

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pyinstaller/macOneFile.spec

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- mode: python -*-
22

3-
# Run with `pyinstaller --windowed --onefile`
3+
# Run with `pyinstaller --windowed --onedir`
44

55
from uilib.fileIO import appVersionStr
66

@@ -17,23 +17,29 @@ a = Analysis(['../main.py'],
1717
win_no_prefer_redirects=False,
1818
win_private_assemblies=False,
1919
cipher=block_cipher,
20-
noarchive=False)
20+
noarchive=False,
21+
target_arch=['x86_64', 'arm64'])
2122
pyz = PYZ(a.pure, a.zipped_data,
2223
cipher=block_cipher)
2324
exe = EXE(pyz,
2425
a.scripts,
25-
a.binaries,
26-
a.zipfiles,
27-
a.datas,
2826
[],
27+
exclude_binaries=True,
2928
name='openMotor',
3029
debug=False,
3130
bootloader_ignore_signals=False,
3231
strip=False,
3332
upx=True,
3433
runtime_tmpdir=None,
35-
console=False )
36-
app = BUNDLE(exe,
34+
console=False)
35+
coll = COLLECT(exe,
36+
a.binaries,
37+
a.zipfiles,
38+
a.datas,
39+
strip=False,
40+
upx=True,
41+
name='openMotor')
42+
app = BUNDLE(coll,
3743
name='openMotor.app',
3844
icon='../resources/oMIconCycles.icns',
3945
version=appVersionStr,

0 commit comments

Comments
 (0)