Auto updating a python executable generated with pyinstaller

16,080

Solution 1

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)

Solution 2

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

Solution 3

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.

Share:
16,080

Related videos on Youtube

Fernando Freitas Alves
Author by

Fernando Freitas Alves

Updated on June 07, 2022

Comments

  • Fernando Freitas Alves
    Fernando Freitas Alves almost 2 years

    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?

    • Torxed
      Torxed over 10 years
      Why not just create a .bat file, schedule it in the windows scheduler to run every boot/shutdown/hour or so?
    • Maciej Gol
      Maciej Gol over 10 years
      @Torxed, Keep in mind you have to run it as SYSTEM, otherwise the command prompt will pop up.
    • Torxed
      Torxed over 10 years
      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
    • Joran Beasley
      Joran Beasley over 10 years
      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
    • Fernando Freitas Alves
      Fernando Freitas Alves over 10 years
      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
    Fernando Freitas Alves over 9 years
    Wow, I'm glad you did this, I'll try it soon!
  • Fernando Freitas Alves
    Fernando Freitas Alves almost 9 years
    I've used Esky with cx freeze and they work great together.
  • Ice Bear
    Ice Bear over 3 years
    Hello! could there be a video that shows how to do this? Thanks!
  • ndemou
    ndemou over 3 years
    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 ;-)
  • Ice Bear
    Ice Bear over 3 years
    don't need it actually. Thanks
  • Delrius Euphoria
    Delrius Euphoria over 3 years
    Only if the repo wasn't archived :(
  • Piyush
    Piyush about 3 years
    @IceBear Have you found any open-source project?
  • Ice Bear
    Ice Bear about 3 years
    @Piyush nopeeee
  • Delrius Euphoria
    Delrius Euphoria about 3 years
    @IceBear Where you able to find any other way around?
  • elams
    elams over 2 years
    @FernandoFreitasAlves Esky has been archived now :(
  • elams
    elams over 2 years
    Hi, are there any good tutorial on the auto-update part using PyUpdater? All I've seen is one demo with wxpython app.
  • PrivateOmega
    PrivateOmega over 2 years
    @elams I am also on the look out for this. Would be great if you could post it below, if you find anything.
  • djvg
    djvg about 2 years
    PyUpdater basically does what is described here, without a separate launcher.