Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto updating a python executable generated with pyinstaller

I have a desktop app that I'm working on and I am using PyInstaller to generate de distribution files.

I have chosen PyInstaller over py2exe because it is very easy to use and I don't need to care about windows dlls, but when I use py2exe I can simply use Esky to autoupdate, but I can't use it with PyInstaller.

So I don't know how to start a auto-updating application. Someone have some thoughts or just know how can I use PyInstaller and esky?

like image 329
Fernando Freitas Alves Avatar asked Dec 16 '13 18:12

Fernando Freitas Alves


People also ask

Which is better py2exe or PyInstaller?

In PyInstaller it is easy to create one exe, By default both create a bunch of exes & dlls. In py2exe its easier to embed manifest file in exe, useful for run as administrator mode in windows vista and beyond. Pyinstaller is modular and has a feature of hooks to include files in the build that you like.

How do I update Python exe?

Updating to a new Python version is easy on a computer running Windows. All you have to do is visit the Python downloads page and download the latest version. Clicking on the button will replace the existing version of Python with the new version. The older version will be removed from your computer.

Does PyInstaller compile Python?

The bundled app does not include any source code. However, PyInstaller bundles compiled Python scripts ( . pyc files).


3 Answers

You can create a launcher application for your main application and add all the update logic there. The launcher application does the following:

Displays a pop up (this gives a quick feedback to the user that the program is loading)

Checks the local and repository versions

if local < remote (say v1.0 < v2.0) then:

.... Check at the remote repository for the existence of an updater application called updater_v2.0.exe.

........ If there is one: download it run it and exit. (see bellow)

........ If there is not: download the latest main application exe and replace the local one (beware of file access rights at this step -- you're trying to write to c:\program files).

if local > remote then:

.... Display an error/warning except if this is a developers workstation (you need a setting for this)

Start up the main application.

The purpose of the updater application is to accommodate cases where fetching a fresh main application exe is not enough. I also use it in order to update the launcher application itself (that's why the launcher is exiting as soon as it runs the updater - BTW give windows a bit of time before trying to overwrite the laucher executable)

like image 89
ndemou Avatar answered Oct 20 '22 01:10

ndemou


There is also PyUpdater. I see it is not cited here

like image 28
ubugnu Avatar answered Oct 19 '22 23:10

ubugnu


I ran into the same issue some time ago--so I wrote a small library (updater4pyi) to do exactly that on Mac OS X, Linux and Windows. You can get it from PyPI for example with

> pip install updater4pyi

The source repository is at: https://github.com/phfaist/updater4pyi.

This is a small and not very mature project. It's meant to be as flexible as possible, not relying for example on any specific gui toolkit. I have done some testing on the different platforms, but there may still be bugs. I hope it might be useful to someone else, too.

like image 6
phfaist Avatar answered Oct 20 '22 01:10

phfaist