I have been exploring the options for how to freeze my package that uses flask-desktop. Qt does a lot of the heavy-lifting, and as such it is a pretty big library.
I experimented with several options to see what I could do. Python versions here indicate explicit support for each package.
| |Python 3.4|Python 3.5|Python 3.6|Runs* |Works**|
|-----------------|----------|----------|----------|-------|-------|
|PyQt4 |Yes |Yes |Yes |? |? |
|PyQt5 (5.8.2) |No |Yes |Yes |Yes |Yes |
|cx-Freeze (5.0.1)|Yes |Yes |Yes |Yes |Yes |
|py2exe (0.9.2.2) |Yes |No |No |Yes |No |
|pyinstaller*** |Yes |Yes*** |No |Yes |No |
*Command executes or package imports without errors
**Result of command is valid (i.e. produces working freeze)
***Supported in dev branch
I have tried using the latest versions of py2exe and pyinstaller with Python 3.4/3.5/3.6 separately with no success. The errors I receive are different and complicated each time, and my debugging and research into it was unsuccessful for each pairing of Python version and either freezer package. I won't have enough time to delve into that anytime soon.
PyQt4 is not a practical option because it lacks some very important features like HiDPI support and it uses deprecated QtWebKit.
PyQt5 is only compatible with Python 3.5 and up because its sip package requires it.
py2exe supports UPX and single file (.exe) output but doesn't go past Python 3.4.
pyinstaller dev branch runs in 3.5, but I could not get it to copy binaries to the output directory properly. Every time I run it I get a error messages about not being able to find Qt5 libs. It's different ones each time I run it.
cx-Freeze, on the other hand, is working with some guidance in setup.py:
build_options = dict(
packages = ['encodings', 'asyncio', 'jinja2'],
...
)
Now this is great. It produces a working freeze but my only remaining concern is how should I turn this 300MB folder of frozen stuff (70 files/folders!) into something a little more manageable (ideally under 30MB)? For example, all of the (pre-compiled) Qt5 libraries are copied into the destination twice, in two different paths: build\exe.win-amd64-3.6 and build\exe.win-amd64-3.6\PyQt5\Qt\bin. I can delete the DLLs in build\exe.win-amd64-3.6 and the program still runs fine. And the dependency QtWebEngineCore.dll weighs in at 65MB (uncompressed) and about 26MB after running it through UPX on -9 maximum compression (that's a good start).
My goal is to minimize the footprint of my application, and currently, my flask-python program is a memory hog:
My flask-desktop program hogging a lotta memory

What suggestions do you have for having (Py)Qt5-based application using QtWebEngine use less memory? Also, I'm not familiar with cx-Freeze, so I would love to know if anyone could suggest how I can reduce the build output size with it or how I might get another package freezer to work with Python 3.5/3.6 and PyQt5.
I feel like I have explored a lot of options here but I am still running into difficult limitations because of Python/package version incompatibilities. Any help is greatly appreciated.