-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeTypeVoiceTip.spec
More file actions
100 lines (90 loc) · 2.25 KB
/
Copy pathWeTypeVoiceTip.spec
File metadata and controls
100 lines (90 loc) · 2.25 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
# -*- mode: python ; coding: utf-8 -*-
"""
PyInstaller spec: 微信输入法语音输入提示音 -> 单文件 exe (无控制台窗口)
瘦身策略:
- 只排除 PIL 的未用 C 扩展 (.pyd 二进制, 占 ~10MB)
- PIL 的 Python 插件模块全保留 (互相依赖, 逐个排除会断链)
- 排除构建工具 (pip/setuptools 等)
打包命令:
pyinstaller WeTypeVoiceTip.spec --clean --noconfirm
产物:
dist/WeTypeVoiceTip.exe (单文件, 无需外部依赖)
"""
from PyInstaller.utils.hooks import collect_submodules
# pystray 的 Windows 后端是动态 import 的, 必须显式收集
hiddenimports = [
"pystray._win32",
"pystray._util",
"pystray._util.win32",
"comtypes.client",
"comtypes.gen",
]
hiddenimports += collect_submodules("pystray")
hiddenimports += collect_submodules("comtypes")
excludes = [
"tkinter",
"unittest",
"pydoc",
"doctest",
"xml",
"email",
"http",
"ftplib",
"imaplib",
"smtplib",
"nntplib",
"telnetlib",
# 构建/打包工具, 不该进 exe
"pip",
"setuptools",
"packaging",
"PyInstaller",
"altgraph",
# PIL 未用的 C 扩展 (二进制, 体积大):
# _avif 7.7MB, _imagingft 2.1MB, _webp 0.4MB, _imagingcms 0.3MB
# 只排除这 4 个二进制, Python 插件全保留保证依赖链完整
"PIL._avif",
"PIL._imagingft",
"PIL._webp",
"PIL._imagingcms",
# PIL 未用的纯 Python 子系统 (不影响插件依赖链)
"PIL.ImageQt",
"PIL.ImageTk",
"PIL.ImageGrab",
"PIL.ImageShow",
"PIL.ImageWin",
]
a = Analysis(
["wetype_voice_tip.py"],
pathex=[],
binaries=[],
datas=[],
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excludes,
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name="WeTypeVoiceTip",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False, # 无控制台窗口 (托盘程序)
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon="app_icon.ico",
)