-
Notifications
You must be signed in to change notification settings - Fork 40
/
install.py
45 lines (37 loc) · 1.43 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
from pathlib import Path
from launch import commit_hash as get_commit_hash
from launch import git, run
REPO_LOCATION = Path(__file__).parent
# git show -s --format=%ct <commit_hash>
LAST_BREAKING_COMMIT_TIME = 1675466396
LAST_BREAKING_COMMIT = "6c6c6636bb123d664999c888cda47a1f8bad635b"
auto_update = os.environ.get("AUTO_SD_PAINT_EXT_AUTO_UPDATE", "False").lower() in {
"true",
"yes",
}
try:
commit_hash = run(f'{git} -C "{REPO_LOCATION}" rev-parse HEAD').strip()
except Exception:
commit_hash = "<none>"
print(f"[auto-sd-paint-ext] Commit hash: {commit_hash}")
auto_commit_hash = get_commit_hash()
try:
cur_commit_time = run(f"{git} show -s --format=%ct {auto_commit_hash}")
if int(cur_commit_time) < LAST_BREAKING_COMMIT_TIME:
print(
f"[auto-sd-paint-ext] Current A1111 commit is OLDER than last breaking commit ({LAST_BREAKING_COMMIT})! Extension might fail to function as expected!!!"
)
except Exception:
pass
if auto_update:
print("[auto-sd-paint-ext] Attempting auto-update...")
try:
run(f'"{git}" -C "{REPO_LOCATION}" pull', "[auto-sd-paint-ext] Pull upstream.")
except Exception as e:
print("[auto-sd-paint-ext] Auto-update failed:")
print(e)
print("[auto-sd-paint-ext] Ensure git was used to install extension.")
else:
print("[auto-sd-paint-ext] Auto-update disabled.")
# NOTE: if we ever get dependencies, we can install them here.