build: 优化PyInstaller打包,排除无关包,exe缩小到68MB

This commit is contained in:
2026-05-08 16:23:44 +08:00
parent a5f4275e19
commit 187068f6cc
+21 -9
View File
@@ -7,20 +7,32 @@ PyInstaller打包脚本
import PyInstaller.__main__ import PyInstaller.__main__
import os import os
BASE = os.path.dirname(os.path.abspath(__file__))
PyInstaller.__main__.run([ PyInstaller.__main__.run([
'web/launcher.py', 'web/launcher.py',
'--name=cDNA_Analyzer', '--name=cDNA_Analyzer',
'--onefile', '--onefile',
'--windowed', '--noconsole',
'--add-data', f'web/templates;templates', '--add-data', f'web/templates;templates',
'--add-data', f'web/static;static', '--add-data', f'web/static;static',
'--hidden-import', 'skimage', # 排除不相关的重量级包(环境里有torch/pandas等)
'--hidden-import', 'scipy.ndimage', '--exclude-module', 'torch',
'--hidden-import', 'matplotlib.backends.backend_agg', '--exclude-module', 'torchvision',
'--collect-all', 'skimage', '--exclude-module', 'torchaudio',
'--noconfirm', '--exclude-module', 'pandas',
'--exclude-module', 'sklearn',
'--exclude-module', 'sqlalchemy',
'--exclude-module', 'pygame',
'--exclude-module', 'zmq',
'--exclude-module', 'IPython',
'--exclude-module', 'jedi',
'--exclude-module', 'numba',
'--exclude-module', 'llvmlite',
'--exclude-module', 'onnxruntime',
'--exclude-module', 'lxml',
'--exclude-module', 'cryptography',
'--exclude-module', 'bcrypt',
'--exclude-module', 'pygments',
'--clean', '--clean',
'--noconfirm',
]) ])
print('\n完成!exe 在 dist/ 目录') print('\n完成!exe 在 dist/cDNA_Analyzer.exe')