Python self-update from git

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.

Answers


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.


Need Your Help

Exporting dataset to Excel file with multiple sheets in ASP.NET

c# asp.net visual-studio-2008 excel-2007 openxml-sdk

In C# ASP.NET 3.5 web application, I need to export multiple datatables (or a dataset) to an Excel 2007 file with multiple sheets, and then provide the user with 'Open/Save' dialog box, WITHOUT sav...

How can I concat column using FluentPDO?

php mysql fluent

Lets say I've table user with columns firstname, lastname and col3