1

Disclaimer: I am still learning and am new to python so I have less knowledge of python than most coders.

I am making a simple desktop app and it is already in .exe file format.

How can I send updates to people who have the app?

I was thinking if I could load some GitHub code or raw code from a website (like Pastebin) when a user opens the file so that every time they open my app they have the latest version of it. I am basically updating it from the GitHub repository and in the python code, it only loads the file from GitHub so I can make changes like most desktop apps (Steam, Spotify, Microsoft Apps, Adobe apps etc). I can explain further if I don't make sense.

Is this possible? If so how can I do this? Are there any ways?

  • 3
    Generally [you shouldn't do this](https://www.reddit.com/r/learnpython/comments/eya73w/autoupdating_my_python_application/) but there's already a topic [here](https://stackoverflow.com/questions/12758088/installer-and-updater-for-a-python-desktop-application) about it, can you explain why that thread didn't help? – Random Davis May 10 '22 at 18:40

1 Answers1

1

You would have to have a different website that has the current version on it. What I usually do for updating is I have a .html file stored somewhere (e.g. DropBox) and the program checks if that .html's contents (no actual HTML in the file, just the version number) match with its version string, and if it doesn't, it appends the version number in the HTML file to a string (e.g. example.com/version-1.0.0, 1.0.0 being the version appended) and downloads that.

You can do HTML requests with urllib and download files with requests.

import urllib.request
import requests
import time

currentVersion = "1.0.0"
URL = urllib.request.urlopen('https://example.com/yourapp/version.html')

data = URL.read()
if (data == currentVersion):
    print("App is up to date!")
else:
    print("App is not up to date! App is on version " + currentVersion + " but could be on version " + data + "!")
    print("Downloading new version now!")
    newVersion = requests.get("https://github.com/yourapp/app-"+data+".exe")
    open("app.exe", "wb").write(newVersion.content)
    print("New version downloaded, restarting in 5 seconds!")
    time.sleep(5)
    quit()
Voxel
  • 64
  • 9
  • Why do you call something a .html file if there is no HTML content in it? Then it's just a text file, so you should call it a .txt file. Note that urllib can just as easily download text files, so there isn't any reason to call it a .html file. – wovano Dec 28 '22 at 09:15