Repository navigation
Expand file tree
/
Copy pathPDOS-Viewer.spec
More file actions
84 lines (73 loc) · 2.15 KB
/
Copy pathPDOS-Viewer.spec
File metadata and controls
84 lines (73 loc) · 2.15 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
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller 打包配置 —— PDOS · 结构分析工作台(Windows 便携版)
构建:
pyinstaller --noconfirm --clean PDOS-Viewer.spec
产物:
dist/PDOS-Viewer/PDOS-Viewer.exe ← 双击即可运行
dist/PDOS-Viewer/_internal/ ← 运行时依赖(QtWebEngine / Qt / matplotlib)
打包后程序的目录约定(见 pdos_viewer.py 顶部 APP_DIR / RES_DIR):
APP_DIR = exe 所在目录 —— 数据文件夹、导出文件、运行期生成的 _viewer.html
RES_DIR = sys._MEIPASS —— 打包进来的只读资源(assets/、3dmol/)
"""
from pathlib import Path
ROOT = Path(SPECPATH)
# 只读资源:程序图标 + 3Dmol.js(运行期需要写 _viewer.html,会复制到 exe 同级 3dmol/)
datas = [
(str(ROOT / "assets" / "app.ico"), "assets"),
(str(ROOT / "3dmol" / "3Dmol-min.js"), "3dmol"),
]
hiddenimports = [
# QtWebEngine 相关(动态导入,显式声明更稳)
"PySide6.QtWebEngineWidgets",
"PySide6.QtWebEngineCore",
"PySide6.QtWebChannel",
"PySide6.QtPrintSupport",
# matplotlib 的 Qt 后端
"matplotlib.backends.backend_qtagg",
"matplotlib.backends.backend_agg",
]
a = Analysis(
[str(ROOT / "pdos_viewer.py")],
pathex=[str(ROOT)],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
"tkinter",
"PyQt5", "PyQt6", "PySide2",
"IPython", "jupyter", "notebook", "pytest",
],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="PDOS-Viewer",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False, # 无控制台窗口(GUI 程序)
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=str(ROOT / "assets" / "app.ico"),
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="PDOS-Viewer",
)