Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller but keeping .py files upgradeable

I've managed to package my PyQt4 app as a "standalone" application on windows, it works.

However this application can upgrade itself, which is done by replacing the actual code written by me (.py files) with new versions, downloaded via the internet.

How can I tell PyInstaller do its job (putting together the DLLs, generating the launcher with the shiny icon, etc), BUT let the .py files untouched?

I need those files directly on disk, in order for the auto-update to work.

like image 725
Flavius Avatar asked Mar 20 '11 01:03

Flavius


People also ask

Does PyInstaller include libraries?

PyInstaller does not include libraries that should exist in any installation of this OS. For example in GNU/Linux, it does not bundle any file from /lib or /usr/lib , assuming these will be found in every system.

Which version of Python does PyInstaller use?

PyInstaller supports Python 3.7 and newer, and correctly bundles many major Python packages such as numpy, matplotlib, PyQt, wxPython, and others. PyInstaller is tested against Windows, MacOS X, and Linux.

What is hidden import in PyInstaller?

--hidden-import. List multiple top-level imports that PyInstaller was unable to detect automatically. This is one way to work around your code using import inside functions and __import__() . You can also use --hidden-import multiple times in the same command.


1 Answers

You can change the spec file to specifically not include files by name (when building lists), then make sure these files are included - I'd have to check whether there's an option to include but not compile.


I've not tried this myself (I use pyInstaller at work but don't have it set up on my home PC) but this is the sort of thing I think should be ok:

a = Analysis(['main.py'])
excluded = ['myfile0.py', 'myfile1.py', 'myfile2.py']
a.scripts = [script from script in a.scripts if script not in excluded]
pyz = PYZ(a.pure)
exe = EXE(a.scripts, pyz, name="main.exe", exclude_binaries=1)
dist = COLLECT(exe, a.binaries, excluded, name="dist")
like image 133
theheadofabroom Avatar answered Oct 05 '22 23:10

theheadofabroom