-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathinstall.py
More file actions
80 lines (62 loc) · 1.7 KB
/
install.py
File metadata and controls
80 lines (62 loc) · 1.7 KB
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
75
76
77
78
79
80
from pathlib import Path
import PyInstaller.__main__
import site
import os
import shutil
import sys
import jsonc
from configure import configure_ocr_model
working_dir = Path(__file__).parent
install_path = working_dir / Path("maapicli")
version = len(sys.argv) > 1 and sys.argv[1] or "v0.0.1"
def install_resource():
configure_ocr_model()
shutil.copytree(
working_dir / "assets",
install_path,
dirs_exist_ok=True,
)
shutil.rmtree(install_path / "MaaCommonAssets")
shutil.copy2(
working_dir / "logo.png",
install_path / "logo.png",
)
shutil.copy2(
working_dir / "update_flag.txt",
install_path / "update_flag.txt",
)
# 删除指定文件,而非文件夹
try:
os.remove(install_path / "custom" / "main.py")
except FileNotFoundError:
pass
try:
os.remove(install_path / "custom" / "Agent_file.py")
except FileNotFoundError:
pass
with open(install_path / "interface.json", "r", encoding="utf-8") as f:
interface = jsonc.load(f)
interface["version"] = version
interface["title"] = f"MAA_snowbreak {version}"
with open(install_path / "interface.json", "w", encoding="utf-8") as f:
jsonc.dump(interface, f, ensure_ascii=False, indent=4)
def install_chores():
shutil.copy2(
working_dir / "README.md",
install_path,
)
shutil.copy2(
working_dir / "LICENSE",
install_path,
)
shutil.copy2(
working_dir / "DISCLAIMER.md",
install_path,
)
shutil.copy2(
working_dir / "CONTACT.md",
install_path,
)
if __name__ == "__main__":
install_resource()
install_chores()