How to update software made with python?

Question:

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?

Asked By: blackscratch22

||

Answers:

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()
Answered By: Voxel

I tried your code and I can’t make it work, can you please give some details

Answered By: Sîrbu Valentin
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.