PyQt/Modular_PyQt_deployment_with_PyInstaller¶
Legacy Wiki Page
This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.
How to distribute only the qt4 dlls and pyqt libraries that your application really needs¶
If you want to finetune the size of a PyQt application, the best way is to recompile Qt/PyQt to use a consolidated module. Basically:
Compile Qt statically (
configure --static). It will build static libraries (.lib) instead of dlls.Compile PyQt with
--consolidate(but *without*--static, since you still want a dynamic .pyd module). Add--enablefor the modules you need and--pluginfor the plugins you need. This will give you a big _qt.pyd with everything inside (no external dependencies), plus small Qt*.pyd wrappers to make your existing code work. You will save space twice because:it will just include the parts you need
it will compress *tons* better (because there are no relocations symbols, more stuff is inlined, etc.).
Give that to PyInstaller trunk with latest UPX (with LZMA support) and its’s done.
Then, you might want to see the output of ArchiveViewer.py run over the final executable, so that you will see the list of all modules that have been brought in. If there’s something that PyInstaller thought you might need but you actually don’t use, you can hand-edit the excludes=[] list in the .spec file to avoid bringing them in.