original push
This commit is contained in:
96
algorithm_V1/build_algorithm.spec
Normal file
96
algorithm_V1/build_algorithm.spec
Normal file
@@ -0,0 +1,96 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
from PyInstaller.utils.hooks import collect_submodules, collect_data_files
|
||||
|
||||
# ========================================================
|
||||
# 1. 工程配置区 (Project Config)
|
||||
# ========================================================
|
||||
block_cipher = None
|
||||
ENTRY_POINT = 'runDecoder.py'
|
||||
APP_NAME = 'Depression_Decoder'
|
||||
|
||||
# ========================================================
|
||||
# 2. 依赖分析 (Dependency Analysis)
|
||||
# ========================================================
|
||||
# 收集 mne, sklearn, scipy 可能遗漏的隐藏导入
|
||||
hidden_imports = [
|
||||
'infer_pth', # 你的动态导入模块
|
||||
'sklearn.utils._cython_blas',
|
||||
'sklearn.neighbors.typedefs',
|
||||
'sklearn.neighbors.quad_tree',
|
||||
'sklearn.tree',
|
||||
'sklearn.tree._utils',
|
||||
]
|
||||
# 自动收集 mne 的子模块
|
||||
hidden_imports += collect_submodules('mne')
|
||||
# 收集 torch 相关的隐式导入(虽然 PyInstaller 通常能处理,但显式更安全)
|
||||
hidden_imports += ['torch', 'torchvision']
|
||||
|
||||
# ========================================================
|
||||
# 3. 资源锚定 (Data Anchoring)
|
||||
# ========================================================
|
||||
# Analysis 中的 datas 用于将文件嵌入到内部(运行时在临时目录或 _internal)
|
||||
# 这里我们留空,改为在 COLLECT 阶段通过 Tree 显式复制到 EXE 旁,
|
||||
# 这样生成的文件夹里能直接看到 model 和 raw_data
|
||||
datas = []
|
||||
|
||||
# 收集 mne 的数据文件(如果需要默认配置)
|
||||
datas += collect_data_files('mne')
|
||||
|
||||
# ========================================================
|
||||
# 4. 构建流程 (Build Process)
|
||||
# ========================================================
|
||||
a = Analysis(
|
||||
[ENTRY_POINT],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
hiddenimports=hidden_imports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=['tkinter', 'PyQt5', 'PySide2', 'IPython'], # 排除 GUI 和交互式库减小体积
|
||||
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=APP_NAME,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=False,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
# ========================================================
|
||||
# 5. 打包模式: OneDir (单文件夹) + 资源旁路
|
||||
# ========================================================
|
||||
# 使用 Tree 将文件夹原样复制到 dist/APP_NAME/ 下
|
||||
# 格式: Tree('源路径', prefix='目标子目录')
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=False,
|
||||
upx_exclude=[],
|
||||
name=APP_NAME,
|
||||
)
|
||||
Reference in New Issue
Block a user