28

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?

Fernando Freitas Alves
  • 3,709
  • 3
  • 26
  • 45
  • 2
    Why not just create a .bat file, schedule it in the windows scheduler to run every boot/shutdown/hour or so? – Torxed Dec 16 '13 at 18:24
  • @Torxed, Keep in mind you have to run it as `SYSTEM`, otherwise the command prompt will pop up. – Maciej Gol Dec 16 '13 at 18:24
  • You could run it in userspace as well and force the prompt to be hidden, but yes there would be a prompt initating. You can also create a Python service script of ~20 rows, have that run a "Pyinstaller" command and install it with `C:> python myservice.py install` – Torxed Dec 16 '13 at 18:26
  • 2
    what we do is have a file on the internet that periodically checks if the version number in the file is greater than the current version prompt user to download new installer... in my experience auto updating is risky business – Joran Beasley Dec 16 '13 at 18:27
  • I think maybe @JoranBeasley solution could be the best for what I am doing. But, yes, it is very difficult to implement. In case the download stops or another problem, I can break the app. – Fernando Freitas Alves Dec 16 '13 at 18:52

4 Answers4

17

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)

ndemou
  • 4,691
  • 2
  • 30
  • 33
  • Hello! could there be a video that shows how to do this? Thanks! – Ice Bear Dec 14 '20 at 06:50
  • 2
    You have high chances of finding an open source app using this method and maybe it would serve you better than a video. I can't share any python code because I've only implemented this in VBScript (didn't enjoy it at all). I *could* make a video for python but why *should* I ;-) – ndemou Dec 14 '20 at 09:36
  • **don't need it actually**. Thanks – Ice Bear Jan 08 '21 at 13:51
  • @IceBear Have you found any open-source project? – Piyush Feb 13 '21 at 19:31
  • @Piyush nopeeee – Ice Bear Feb 17 '21 at 12:02
  • @IceBear Where you able to find any other way around? – Delrius Euphoria Apr 20 '21 at 00:19
  • 2
    [PyUpdater](https://github.com/Digital-Sapphire/PyUpdater) basically does what is described here, without a separate launcher. – djvg Mar 17 '22 at 07:56
  • 1
    @djvg PyUpdater is actually no longer being maintained use at your own risk – Cave Johnson123 Sep 30 '22 at 07:46
  • @CaveJohnson123 True, PyUpdater was recently archived. As an alternative, we now have [tufup](https://github.com/dennisvang/tufup). – djvg Sep 30 '22 at 07:52
  • @djvg Isn't tufup largely based off of Pyupdater? I suspect it might also become deprecated in the future if it is – Cave Johnson123 Sep 30 '22 at 07:55
  • @CaveJohnson123 No, `tufup` is a brand new package based on `python-tuf` ([The Update Framework](https://theupdateframework.io/)). It was *inspired* by PyUpdater and provides the same basic functionality, but it is completely independent of pyupdater, and offers better security. Development of `tufup` was actually started because PyUpdater had been inactive for so long. – djvg Sep 30 '22 at 08:00
11

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

djvg
  • 11,722
  • 5
  • 72
  • 103
ubugnu
  • 1,004
  • 2
  • 15
  • 30
  • 1
    Hi, are there any good tutorial on the auto-update part using PyUpdater? All I've seen is one demo with wxpython app. – elams Jan 19 '22 at 07:43
  • 1
    @elams I am also on the look out for this. Would be great if you could post it below, if you find anything. – PrivateOmega Jan 19 '22 at 20:07
  • There's also the [tufup](https://github.com/dennisvang/tufup) package, with [example application](https://github.com/dennisvang/tufup-example). – djvg Aug 01 '22 at 11:38
7

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.

phfaist
  • 253
  • 4
  • 6
0

as of today pyinstaller has only experimental python3 support. If anyone wants to use esky i would recommend using cx freeze. It supports python 2 and 3 and works on linux mac and windows

You are then able to use esky. Esky has the advantage of working with a bootstrap mechanism so that you always have at least one runnable version installed.

timeyyy
  • 654
  • 9
  • 20