自动更新程序+自动pip包安装

This commit is contained in:
qingxu fu 2023-04-09 23:56:24 +08:00
parent 6ce9b724ec
commit 869de46078

View File

@ -67,12 +67,15 @@ def patch_and_restart(path):
'另外您可以随时在history子文件夹下找回旧版的程序。')
shutil.copyfile('config.py', 'config_private.py')
distutils.dir_util.copy_tree(path+'/chatgpt_academic-master', './')
print('更新完成您可以随时在history子文件夹下找回旧版的程序5s之后重启')
import subprocess
print('更新包依赖中……')
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
print('更新完成您可以随时在history子文件夹下找回旧版的程序5s之后重启如果没能重启成功您需要手动安装新增的依赖库 `python -m pip install -r requirements.txt` ')
for i in reversed(range(5)):
time.sleep(1)
print(i)
print(' ------------------------------ -----------------------------------')
os.execl(sys.executable, *sys.argv)
os.execl(sys.executable, sys.executable, *sys.argv)
def get_current_version():
@ -107,10 +110,11 @@ def auto_update():
current_version = f.read()
current_version = json.loads(current_version)['version']
if (remote_version - current_version) >= 0.05:
print(
from colorful import print亮黄
print亮黄(
f'\n新版本可用。新版本:{remote_version},当前版本:{current_version}{new_feature}')
print('1Github更新地址:\nhttps://github.com/binary-husky/chatgpt_academic\n')
user_instruction = input('2是否一键更新代码Y/y+回车=确认,输入其他/无输入+回车=不更新)?')
user_instruction = input('2是否一键更新代码Y+回车=确认,输入其他/无输入+回车=不更新)?')
if user_instruction in ['Y', 'y']:
path = backup_and_download(current_version, remote_version)
try: