-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaao.spec
More file actions
158 lines (142 loc) · 4.99 KB
/
Copy pathaao.spec
File metadata and controls
158 lines (142 loc) · 4.99 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller spec:把 aao.app 打包成 onedir。
资源策略:resource/data/config **外置**在 exe 同级目录(用户可改时间轴/校准/配置),
不打进 _internal。打包后需手动把 resource/ data/ config/ 复制到 dist/aao.app/ 旁。
maafw 的 MaaFramework.dll 等(maa/bin/)随 --collect-all maa 打进 _internal/maa/bin,
运行时由 configure_paths() 设 MAAFW_BINARY_PATH 指向。
打包:uv run pyinstaller aao.spec --noconfirm
首次需先 uv pip install pyinstaller(已在 dev 依赖外,临时装)。
"""
from PyInstaller.utils.hooks import collect_all, collect_submodules
# maafw:收 Python 模块 + maa/bin 下的 DLL(ctypes 加载,PyInstaller 静态分析发现不了)
maa_datas, maa_binaries, maa_hiddenimports = collect_all("maa")
# registry 用 importlib.import_module("custom.action") 动态扫描,
# PyInstaller 发现不了 custom.action/reco 下的子模块,必须显式收集。
custom_hiddenimports = collect_submodules("custom") + collect_submodules("aao")
hiddenimports = (
[
# loguru enqueue=True 用 multiprocessing,需显式收
"multiprocessing",
"multiprocessing.spawn",
# websockets / json5 有动态导入
"websockets",
"json5",
"json5.lib",
# aao.utils.logger 用 _PercentLogger,确保收集
"aao.utils.logger",
]
+ maa_hiddenimports
+ custom_hiddenimports
)
a = Analysis(
["aao/app.py"],
pathex=[],
binaries=maa_binaries,
datas=maa_datas, # 只打 maafw 自带资源,项目 resource/data/config 外置
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[
# 瘦身:排除用不到的 PySide6 大模块
"PySide6.Qt3DAnimation",
"PySide6.Qt3DCore",
"PySide6.Qt3DExtras",
"PySide6.Qt3DInput",
"PySide6.Qt3DLogic",
"PySide6.Qt3DRender",
"PySide6.QtCharts",
"PySide6.QtDataVisualization",
"PySide6.QtGraphs",
"PySide6.QtLocation",
"PySide6.QtMultimedia",
"PySide6.QtMultimediaWidgets",
"PySide6.QtNetworkAuth",
"PySide6.QtNfc",
"PySide6.QtOpenGL",
"PySide6.QtOpenGLWidgets",
# QML / Quick 全家桶:我们纯 QtWidgets,不用 QML
"PySide6.QtQml",
"PySide6.QtQuick",
"PySide6.QtQuick3D",
"PySide6.QtQuickControls2",
"PySide6.QtQuickWidgets",
"PySide6.QtQmlModels",
"PySide6.QtQmlWorkerScript",
"PySide6.QtPdf",
"PySide6.QtPdfWidgets",
"PySide6.QtPositioning",
"PySide6.QtQml",
"PySide6.QtQuick",
"PySide6.QtQuick3D",
"PySide6.QtQuickControls2",
"PySide6.QtQuickWidgets",
"PySide6.QtRemoteObjects",
"PySide6.QtScxml",
"PySide6.QtSensors",
"PySide6.QtSerialBus",
"PySide6.QtSerialPort",
"PySide6.QtSpatialAudio",
"PySide6.QtSql",
"PySide6.QtStateMachine",
"PySide6.QtSvg",
"PySide6.QtSvgWidgets",
"PySide6.QtTextToSpeech",
"PySide6.QtUiTools",
"PySide6.QtWebChannel",
"PySide6.QtWebEngineCore",
"PySide6.QtWebEngineQuick",
"PySide6.QtWebEngineWidgets",
"PySide6.QtWebSockets",
"PySide6.QtXml",
"tkinter",
"unittest",
"pydoc",
],
noarchive=False,
)
# 瘦身:从 binaries 删除确定不用的 DLL。
# QML/Quick dll(excludes 已挡 import,但 PyInstaller 仍可能收集 Qt6Quick.dll 等本体)
# + opengl32sw.dll(软件 OpenGL 兜底,桌面客户端有 GPU 不需要)
# + 不用的 maafw control unit(Win32-only,不用 ADB/Gamepad/Replay/Record)
_STRIP_DLLS = (
"Qt6Quick", "Qt6Qml", "Qt6Quick3D", "Qt6QuickControls2",
"Qt6QuickShapes", "Qt6QuickTemplates2", "Qt6QuickParticles",
"Qt6QmlModels", "Qt6QmlWorkerScript", "Qt6LabsQml", "Qt6LabsSettings",
"Qt6Pdf", "Qt6PdfWidgets",
"opengl32sw",
"d3dcompiler",
"MaaAdbControlUnit",
"MaaGamepadControlUnit",
"MaaReplayControlUnit",
"MaaRecordControlUnit",
"MaaCustomControlUnit",
)
def _should_strip(dest: str) -> bool:
name = dest.replace("\\", "/").rsplit("/", 1)[-1].lower()
base = name.rsplit(".", 1)[0]
return any(base == s.lower() for s in _STRIP_DLLS)
a.binaries = [b for b in a.binaries if not _should_strip(b[0])]
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="aao.app",
console=False, # windowed 模式:无控制台黑窗。日志靠 debug/aao/*.log + UI 面板 + crash.log
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon="logo.ico", # 打包时由 PyInstaller 嵌入(不损坏 PKG;不用 rcedit)
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False, # UPX 压 PyInstaller bootloader 会致 PKG archive 加载失败
upx_exclude=[],
name="aao.app",
)