Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create update mechanism #93

Closed
wants to merge 14 commits into from
Closed

Create update mechanism #93

wants to merge 14 commits into from

Conversation

r58Playz
Copy link

@r58Playz r58Playz commented Apr 19, 2019

This updates the game using requests.

EDIT: The git function has been removed in commit 947bfad

Closes #71

@Nebual
Copy link
Collaborator

Nebual commented Apr 19, 2019

Good idea, but I'm not sure this is an ideal approach...

  1. At this stage of development, 99% of people running this are going to be using the git version anyway, in which case updating is a simple git pull + relaunch. Once the game is meaningful to users who wouldn't use git directly, we'd probably produce packaged Releases (including pyglet/dependencies), possibly as a self-contained .exe. Travis/Appveyer can automate this.
  2. The sorts of users who can't be served by a git pull likely don't have git installed to be able to run git clone. Replacing the git clone with something like (untested)
r = urllib.request.urlopen('https://github.com/boskee/Minecraft/archive/master.zip')
with zipfile.ZipFile(BytesIO(r.read())) as z:
    z.extractall()

is more portable (non-Windows), is much more efficient/fast than a git clone, doesn't involve temporary files, and avoids run() in favour of pure python.
3. You still need to manually relaunch the game, hot-reloading would be sweet for development (and useful for this)... you might also be able to get away with replacing python main.py with python update_and_run_main.py which checks for + updates first, prior to import'ing/exec'ing the rest of the game, though that would prevent you from having a nice pyglet Update button.

@r58Playz
Copy link
Author

That's fixed...

@r58Playz
Copy link
Author

r58Playz commented Apr 20, 2019

Replacing the git clone with something like (untested)

r = urllib.request.urlopen('https://github.com/boskee/Minecraft/archive/master.zip')
with zipfile.ZipFile(BytesIO(r.read())) as z:
    z.extractall()

That works, but there's a catch: It updates update.py.

@r58Playz
Copy link
Author

So, we need to use temporary files so that while updating, the updater does not update itself(the updater overwrites the file it is in).

@r58Playz
Copy link
Author

Oh, in the imports the urllif.request needs to be changed to urllib.request.
Also, append this after all the imports:from io import BytesIO

@r58Playz r58Playz closed this Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installation matters
2 participants