mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-02-05 08:20:45 +01:00
Installer: don't ignore .whl requirements if the commit has changed
By the user manually switching branches or calling git pull.
This commit is contained in:
parent
1c9dfa871b
commit
053911b629
45
one_click.py
45
one_click.py
@ -1,6 +1,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
@ -148,6 +149,11 @@ def check_env():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def get_current_commit():
|
||||||
|
result = run_cmd("git rev-parse HEAD", capture_output=True, environment=True)
|
||||||
|
return result.stdout.decode('utf-8').strip()
|
||||||
|
|
||||||
|
|
||||||
def clear_cache():
|
def clear_cache():
|
||||||
run_cmd("conda clean -a -y", environment=True)
|
run_cmd("conda clean -a -y", environment=True)
|
||||||
run_cmd("python -m pip cache purge", environment=True)
|
run_cmd("python -m pip cache purge", environment=True)
|
||||||
@ -351,10 +357,21 @@ def update_requirements(initial_installation=False, pull=True):
|
|||||||
else:
|
else:
|
||||||
requirements_file = "requirements" + ("_noavx2" if not cpu_has_avx2() else "") + ".txt"
|
requirements_file = "requirements" + ("_noavx2" if not cpu_has_avx2() else "") + ".txt"
|
||||||
|
|
||||||
# Check and clear the wheels changed flag
|
# Load state from JSON file
|
||||||
wheels_changed = os.path.exists('.wheels_changed_flag')
|
state_file = '.installer_state.json'
|
||||||
if wheels_changed:
|
wheels_changed = False
|
||||||
os.remove('.wheels_changed_flag')
|
if os.path.exists(state_file):
|
||||||
|
with open(state_file, 'r') as f:
|
||||||
|
last_state = json.load(f)
|
||||||
|
|
||||||
|
wheels_changed = last_state.get('wheels_changed', False)
|
||||||
|
else:
|
||||||
|
last_state = {}
|
||||||
|
|
||||||
|
# Check wheels changed from state file and commit differences
|
||||||
|
current_commit = get_current_commit()
|
||||||
|
if last_state.get('last_commit') != current_commit:
|
||||||
|
wheels_changed = True
|
||||||
|
|
||||||
if pull:
|
if pull:
|
||||||
# Read .whl lines before pulling
|
# Read .whl lines before pulling
|
||||||
@ -387,12 +404,30 @@ def update_requirements(initial_installation=False, pull=True):
|
|||||||
if before_hashes[file] != after_hashes[file]:
|
if before_hashes[file] != after_hashes[file]:
|
||||||
print_big_message(f"File '{file}' was updated during 'git pull'. Please run the script again.")
|
print_big_message(f"File '{file}' was updated during 'git pull'. Please run the script again.")
|
||||||
if before_pull_whl_lines != after_pull_whl_lines:
|
if before_pull_whl_lines != after_pull_whl_lines:
|
||||||
open('.wheels_changed_flag', 'w').close()
|
wheels_changed = True
|
||||||
|
|
||||||
|
# Save state before exiting
|
||||||
|
current_state = {
|
||||||
|
'last_commit': current_commit,
|
||||||
|
'wheels_changed': wheels_changed
|
||||||
|
}
|
||||||
|
|
||||||
|
with open(state_file, 'w') as f:
|
||||||
|
json.dump(current_state, f)
|
||||||
|
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
wheels_changed = wheels_changed or (before_pull_whl_lines != after_pull_whl_lines)
|
wheels_changed = wheels_changed or (before_pull_whl_lines != after_pull_whl_lines)
|
||||||
|
|
||||||
|
# Save current state
|
||||||
|
current_state = {
|
||||||
|
'last_commit': current_commit,
|
||||||
|
'wheels_changed': wheels_changed
|
||||||
|
}
|
||||||
|
|
||||||
|
with open(state_file, 'w') as f:
|
||||||
|
json.dump(current_state, f)
|
||||||
|
|
||||||
if os.environ.get("INSTALL_EXTENSIONS", "").lower() in ("yes", "y", "true", "1", "t", "on"):
|
if os.environ.get("INSTALL_EXTENSIONS", "").lower() in ("yes", "y", "true", "1", "t", "on"):
|
||||||
install_extensions_requirements()
|
install_extensions_requirements()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user