-
Notifications
You must be signed in to change notification settings - Fork 508
/
install.py
74 lines (59 loc) · 2.41 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
from pathlib import Path
from launch import git, run
import launch
import sys
# launch.run(f'git pull', f"updating auto-photoshop plugin",
# f"Couldn't update auto-photoshop plugin")
REPO_LOCATION = Path(__file__).parent
# auto_update = os.environ.get("AUTO_UPDATE", "True").lower() in {"true", "yes"}
auto_update = True
extension_branch = "master"
# extension_branch = "horde_native"
# extension_branch = "auto_extension_ccx_1_1_7"
if auto_update:
print("[Auto-Photoshop-SD] Attempting auto-update...")
try:
checkout_result = run(
f'"{git}" -C "{REPO_LOCATION}" checkout {extension_branch}',
"[Auto-Photoshop-SD] switch branch to extension branch.",
)
print("checkout_result:", checkout_result)
branch_result = run(
f'"{git}" -C "{REPO_LOCATION}" branch',
"[Auto-Photoshop-SD] Current Branch.",
)
print("branch_result:", branch_result)
fetch_result = run(
f'"{git}" -C "{REPO_LOCATION}" fetch', "[Auto-Photoshop-SD] Fetch upstream."
)
print("fetch_result:", fetch_result)
pull_result = run(
f'"{git}" -C "{REPO_LOCATION}" pull', "[Auto-Photoshop-SD] Pull upstream."
)
print("pull_result:", pull_result)
except Exception as e:
print("[Auto-Photoshop-SD] Auto-update failed:")
print(e)
print("[Auto-Photoshop-SD] Ensure git was used to install extension.")
# print("Auto-Photoshop-SD plugin is installing")
import pkg_resources
def install_or_update_package(package_name, package_version):
if not launch.is_installed(package_name):
launch.run_pip(
f"install {package_name}=={package_version}",
"requirements for Auto-Photoshop Image Search",
)
else: # it's installed but we need to check for update
version = pkg_resources.get_distribution(package_name).version
if version != package_version:
print(
f"{package_name} version: {version} will update to version: {package_version}"
)
launch.run_pip(
f"install {package_name}=={package_version}",
"update requirements for Auto-Photoshop Image Search",
)
# Now we can use this function to install or update the packages
install_or_update_package("duckduckgo_search", "3.9.9")
install_or_update_package("httpx", "0.24.1")