generated from MaaXYZ/MaaPracticeBoilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.py
45 lines (36 loc) · 1.15 KB
/
build.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 PyInstaller.__main__
import os
import site
# 获取 site-packages 目录列表
site_packages_paths = site.getsitepackages()
# 查找包含 maa/bin 的路径
maa_bin_path = None
for path in site_packages_paths:
potential_path = os.path.join(path, 'maa', 'bin')
if os.path.exists(potential_path):
maa_bin_path = potential_path
break
if maa_bin_path is None:
raise FileNotFoundError("未找到包含 maa/bin 的路径")
# 构建 --add-data 参数
add_data_param = f'{maa_bin_path}{os.pathsep}maa/bin'
# 查找包含 MaaAgentBinary 的路径
maa_bin_path2 = None
for path in site_packages_paths:
potential_path = os.path.join(path, 'MaaAgentBinary')
if os.path.exists(potential_path):
maa_bin_path2 = potential_path
break
if maa_bin_path2 is None:
raise FileNotFoundError("未找到包含 MaaAgentBinary 的路径")
# 构建 --add-data 参数
add_data_param2 = f'{maa_bin_path2}{os.pathsep}MaaAgentBinary'
# 运行 PyInstaller
PyInstaller.__main__.run([
'src/main.py',
'--onefile',
'--name=ZZZ_Copilot',
f'--add-data={add_data_param}',
f'--add-data={add_data_param2}',
'--clean',
])