This tool transforms the python application into a native executable one. The good thing is that the application doesn't need any dependency on the host system. The web server Flask is included, so the native executable run a server.
I write down briefly my initial research:
- I was playing with PyInstaller and it's able to launch the our application but I found some application malfunction and a huge distribution size, around 1 GB
The tool, by default, bundled a lot of useless modules.
I realized the vast majority of the data was taken up by a 'share/' folder that was a folder with graphical resources (for GLib), most of them icons! If I removed manually that folder and everything worked the same, the size reduced to 115 MB what was a manageable size.
The next step was to try not to generate that amount of useless data. I've been testing the exclusion of several seemly useless (the app seemed to work the same) modules and this command seems to work and produces only a 64MB dist
The final command was:
pyinstaller -F --exclude-module=tkinter --exclude-module=matplotlib --add-data "static:static" -n elGUI main.py (executed on the
app/ folder). The -F option can be added to get the one file application executable.
The module matplotlib caused the inclusion of a lot of graphic libraries dependencies. I guess matplotlib is a dependency of some necessary modules (scipy) (because of that the tool included it)
So, finally the bundle size is not big (around 80MB) The necessary scientific packages turned into linux native compiled libraries are not specially big: e.g. numpy (34MB), scipy (16MB)
Python module version issue
Despite that I run PyInstaller from a virtual environment it seemed to be using the module (version) installed on the system. I updated the system module version and everything went right. So, It seems PyInstaller reads the python modules installed on the system (regardless of it is being executed on a virtual environment)
One file option issue
When the whole application was packaged in one executable file (PyInstaller onefile option) we got execution errors related to the app static resources, they were not found. The application resources are unzipped on a temporary folder in the appropriate temp-folder location for the host OS.
Sebastian found out a fix to this (https://github.com/ciscomonkey/flask-pyinstaller): if the application is run as a bundle, the PyInstaller bootloader extends the
sys module by a flag
frozen=True and sets the app path into variable