-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild_windows.spec
More file actions
107 lines (99 loc) · 3.35 KB
/
Copy pathbuild_windows.spec
File metadata and controls
107 lines (99 loc) · 3.35 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
# -*- mode: python ; coding: utf-8 -*-
# ============================================================================
# Video Analysis Pro — Windows 打包配置 (PyInstaller onedir)
# 构建: py -3.10 -m PyInstaller build_windows.spec --noconfirm
# 产物: dist/VideoAnalysisPro/VideoAnalysisPro.exe (onedir, 启动快、误报少)
#
# 设计要点:
# - onedir 而非 onefile: 启动快 ~10x、杀软误报率显著更低
# - config/ 提示词模板打进包
# - FFmpeg 由 imageio-ffmpeg 自带二进制提供(无外部依赖)
# - 模型 (yolo11n.pt 等) 首次运行由应用自动下载到 models/,不塞进安装包
# ============================================================================
import os
from PyInstaller.utils.hooks import collect_all, collect_data_files
block_cipher = None
datas = [
("config", "config"),
("resources", "resources"),
]
binaries = []
hiddenimports = []
# ultralytics / torch 家族需要完整收集
for pkg in ("ultralytics",):
r = collect_all(pkg)
datas += r[0]; binaries += r[1]; hiddenimports += r[2]
# chromadb 动态导入链
for pkg in ("chromadb",):
try:
r = collect_all(pkg)
datas += r[0]; binaries += r[1]; hiddenimports += r[2]
except Exception:
pass
hiddenimports += [
"torch", "torchvision", "torchaudio",
"cv2", "ultralytics.nn.tasks",
"sentence_transformers",
"faster_whisper",
"scenedetect",
"moviepy",
# v9.0.0:matplotlib 用 Agg 后端(Web/Electron 不需要 Qt 后端)
"matplotlib.backends.backend_agg",
# v9.0.0:Web 后端 FastAPI/uvicorn
"fastapi", "uvicorn", "uvicorn.logging",
"sse_starlette", "multipart",
"pydantic", "pydantic_settings",
]
a = Analysis(
["launcher.py"],
pathex=[os.path.abspath(".")],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
# 大体积可选依赖不进默认包(P2 决策: OCR 可选下载)
"paddle", "paddleocr", "paddlepaddle",
"pyannote", "decord",
"gradio",
# 开发工具
"pytest", "pyinstaller",
# 多 Qt 绑定冲突: PyInstaller 不支持同时打包多个 Qt 绑定。
# v9.0.0 起桌面壳走 Electron,后端纯 FastAPI,所有 Qt 绑定一律排除。
"PyQt5", "PyQt5.QtCore", "PyQt5.QtWidgets", "PyQt5.QtGui",
"PyQt6", "PyQt6.QtCore", "PyQt6.QtWidgets", "PyQt6.QtGui",
"PyQt6.QtMultimedia", "PyQt6.QtMultimediaWidgets",
"PySide2", "PySide6",
"IPython", "jedi", "parso", # REPL 依赖,桌面应用不需要
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="VideoAnalysisPro",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False, # GUI 应用不出黑窗口
disable_windowed_traceback=False,
icon="resources/app_icon.ico", # 听风公司 logo(见 desktop/assets/icon.svg)
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name="VideoAnalysisPro",
)