indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.49k stars 239 forks source link

Size Optimization? #220

Open BiatuAutMiahn opened 4 years ago

BiatuAutMiahn commented 4 years ago

Can we do anything to optimize the size of the resulting exe?

indygreg commented 4 years ago

The easiest way is to not package module sources, just bytecode. You can also cut down on the extensions being distributed, as some of the library dependencies are a few MB.

Running strip on the resulting executable should also help. (This would be a good feature to add.) Although running strip removes debug symbols and makes crashes harder to dissect. Tradeoffs.

BiatuAutMiahn commented 4 years ago

right, ty

BiatuAutMiahn commented 4 years ago

Ok I need to add, Im using Win10 as my platform with x86_64-pc-windows-msvc, nightly

indygreg commented 4 years ago

On Windows, debug symbols are not included in the binary. So the best way to cut down binary size would be to not include unused extensions, module sources, and modules entirely.

Do you find PyOxidizer's binaries to be much larger than a regular Python install? (Because they should be roughly the same size.)

BiatuAutMiahn commented 4 years ago

They are, however with upx I can get the binary down to 7mb

kellyjonbrazil commented 4 years ago

I noticed that when I packaged my binary created with pyoxidizer inside a deb or rpm, the package is about a third of the size of the binary (73Mb to 25Mb), which means it must be pretty compressible. Not sure if it makes sense to have an option to compress inside the binary to bring the size down. It is nice that the resulting rpm or deb is moderately sized.