Making app package smaller

38 views
Skip to first unread message

Elliott Balsley

unread,
Dec 29, 2020, 3:56:09 AM12/29/20
to PyInstaller
Even for a very simple python code, PyInstaller adds a lot of extra files.  Is there a recommended way to remove some of this to make the app smaller?  For example, a Python code with just one line:

print('Hello world.')

The app package is 13.5 MB on macOS, or 5.9MB in one-file mode.  Some of the largest files in the package are:
libcrypto.1.1.dylib 2.8M
libssl.1.1.dylib 556K
libncursesw.5.dylib 433K

Pax Williams

unread,
Mar 6, 2021, 11:13:33 AM3/6/21
to PyInstaller

Elliott Balsley

unread,
Apr 6, 2021, 2:45:51 AM4/6/21
to PyInstaller
Thanks for the tip, I had not tried that.  I installed UPX (version 3.96 from home-brew) and it saved me a whopping 0.0001 percent.  The single file binary for "hello world" went from 5870240 bytes to 5870233 bytes.

bwoodsend

unread,
Apr 6, 2021, 11:37:04 AM4/6/21
to PyInstaller

UPX is great for onedir builds but both UPX and onefile use zlib compression so using both simultaneously won’t accomplish anything. The OpenSSL stuff (libcrypto and libssl) are optional components of Python so if you were really determined you could compile Python itself from source with those components disabled then run PyInstaller but it’ll be a lot of work.

Elliott Balsley

unread,
Apr 6, 2021, 12:01:50 PM4/6/21
to PyInstaller

Okay, good idea.  That does sound like a lot of work though, probably not worth it for me.  I'm just curious.

For what it's worth, UPX makes no difference on a onedir build either.  See below, it's exactly the same bytes.  Is there some way to see if UPX is actually working?

 % echo "print('Hello world.')" > helloworld.py
 % pyinstaller --noupx helloworld.py

 % du -d 1 dist       
26528 dist/helloworld
26528 dist

 % rm -rf dist build       
 % pyinstaller helloworld.py
 % du -d 1 dist                     
26528 dist/helloworld
26528 dist
Reply all
Reply to author
Forward
0 new messages