Add live update

This commit is contained in:
hlohaus 2025-06-13 08:11:02 +02:00
parent f71a729948
commit 1525fcd3e0
5 changed files with 25 additions and 8 deletions

19
etc/tool/update.py Normal file
View file

@ -0,0 +1,19 @@
import os
from g4f import version
from subprocess import call, STDOUT
if __name__ == "__main__":
if not os.getenv("G4F_LIVE"):
print("Live mode is not enabled. Exiting update script.")
exit(0)
command = ["git", "fetch"]
call(command, stderr=STDOUT)
command = ["git", "reset", "--hard", "master"]
call(command, stderr=STDOUT)
command = ["git" ,"pull", "origin", "main"]
call(command, stderr=STDOUT)
current_version = version.get_git_version()
with open("g4f/debug.py", "a") as f:
f.write(f"\nversion: str = '{current_version}'\n")
command = ["pip", "install", "-U", "-r" , "requirements-slim.txt"]
call(command, stderr=STDOUT)