2

I'm developing a game in Python, and I would like to implement a system where the user could select if they want to receive auto-updates from git, and if they do, if they want to update from the "stable" branch or the "beta" branch.

Is there a simple way to do this, such as a library to allow python to access git? I'd like to avoid having to set up a web host that can send the files over ftp when I have a git repository that already holds all of the code I need. I would prefer a way that doesn't require the user to have git installed outside of the game, but if I have to require git to allow updates I am okay with it.

If it helps, we can assume that the game's updater is self-contained and will never need to update itself.

Matthew Fournier
  • 1,077
  • 2
  • 17
  • 32

1 Answers1

3

pip can install from git directly (you can choose a branch, tag if you want). pip is bundled with recent Python versions (2.7.9+, 3.4+).

  • update your program e.g.:

    subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-U',
            'git+...uri...#egg=your_package'])
    
  • restart it:

    os.execv(sys.executable, sys.argv + ['--updated'])
    

Beware: it is very simplistic. Review how other programs with similar requirments do it.

jfs
  • 399,953
  • 195
  • 994
  • 1,670