-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathhackbot.spec
More file actions
117 lines (108 loc) · 2.39 KB
/
hackbot.spec
File metadata and controls
117 lines (108 loc) · 2.39 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
# PyInstaller spec: 打包 Hackbot 为各平台可执行程序
# 使用方式: pyinstaller hackbot.spec
# 产物: dist/hackbot/ 目录,内含 hackbot(或 hackbot.exe)及依赖
# 使用 onedir 模式避免单文件体积超过 4GB 导致 Linux CI 报 struct.error
# Linux 下启用 noarchive 避免 PYZ 过大导致 CArchiveWriter struct.error
import sys
IS_LINUX = sys.platform == 'linux'
# 顶层包与模块(与 pyproject.toml [tool.setuptools] packages 对齐)
TOP_LEVEL = [
'hackbot',
'core',
'core.agents',
'core.patterns',
'core.attack_chain',
'core.memory',
'skills',
'hackbot_config',
'controller',
'crawler',
'database',
'defense',
'payloads',
'prompts',
'system',
'tools',
'tui',
'utils',
'router',
]
# 运行时可能动态加载的库
HIDDEN_IMPORTS = [
'langchain',
'langchain_core',
'langchain_community',
'langchain_openai',
'langchain_ollama',
'pydantic',
'pydantic_settings',
'dotenv',
'typer',
'rich',
'sqlalchemy',
'yaml',
'tiktoken',
'httpx',
'aiohttp',
'openai',
'router.main',
'hackbot.launch_tui',
] + TOP_LEVEL
# 数据文件:提示词模板等
DATAS = [
('prompts/templates', 'prompts/templates'),
]
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=DATAS,
hiddenimports=HIDDEN_IMPORTS,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
'tkinter',
'matplotlib',
'PIL',
'pytest',
'IPython',
# 项目不依赖 PyTorch/TensorFlow,排除以减小体积、加快构建
'torch',
'torchvision',
'torchaudio',
'tensorflow',
'keras',
'tensorboard',
'onnxruntime',
],
noarchive=IS_LINUX,
optimize=0,
)
pyz = PYZ(a.pure)
# onedir 模式:可执行文件 + 依赖目录,避免单文件超过 4GB 限制(Linux CI struct.error)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='hackbot',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
name='hackbot',
)