-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSerialUI.spec
More file actions
150 lines (137 loc) · 3.95 KB
/
SerialUI.spec
File metadata and controls
150 lines (137 loc) · 3.95 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Add folders you want to bundle
import os
from PyInstaller.building.build_main import Analysis, PYZ, EXE, COLLECT, Tree
from config import USE_FASTPLOTLIB, USE_BLE
block_cipher = None
console_mode = os.environ.get("SERIALUI_CONSOLE", "").strip().lower() in ("1", "true", "yes", "on")
# Path to project root (where this spec file lives)
proj_root = os.path.abspath(os.getcwd())
# Entry point of your app:
entry_script = os.path.join(proj_root, "SerialUI.py")
datas = [
("assets", "assets"),
("README.md", "."),
]
excludes = [
# Ensure only PyQt6 is collected. The source contains PyQt5 fallback imports,
# but frozen builds should ship exactly one Qt binding.
"PyQt5",
"PyQt5.sip",
"PySide2",
"PySide6",
# Exclude GUI stacks not used by this Qt app.
"IPython",
"ipykernel",
"gi",
"gi.repository",
"tkinter",
"PIL.ImageTk",
# Avoid GTK/Tk backend pull-in from matplotlib in frozen Qt app.
"matplotlib",
"matplotlib.backends.backend_gtk3",
"matplotlib.backends.backend_gtk3agg",
"matplotlib.backends.backend_gtk3cairo",
"matplotlib.backends.backend_gtk4",
"matplotlib.backends.backend_gtk4agg",
"matplotlib.backends.backend_gtk4cairo",
"matplotlib.backends.backend_tkagg",
"matplotlib.backends.backend_tkcairo",
# Debug helper is guarded out in frozen mode; avoid bundling it.
"debugpy",
]
# In default config we do not use fastplotlib. Exclude its heavy dependency stack
# to prevent multi-GB Linux bundles from optional CUDA/OpenCV/media packages.
if not USE_FASTPLOTLIB:
excludes += [
"fastplotlib",
"pygfx",
"wgpu",
"rendercanvas",
"imgui_bundle",
"cv2",
"imageio",
"imageio_ffmpeg",
"av",
"uharfbuzz",
"wx",
"vtk",
"pandas",
"dask",
"zarr",
"numcodecs",
"h5py",
"botocore",
"sphinx",
"pytest",
]
# BLE stack is optional in app config.
if not USE_BLE:
excludes += [
"bleak",
"bleak.backends",
]
a = Analysis(
[entry_script],
pathex=[proj_root],
binaries=[],
datas=datas,
hiddenimports=[
# Add any modules here that PyInstaller might miss, e.g.:
# "pkg_resources.py2_warn",
# "some_dynamic_imported_module",
],
hookspath=[],
hooksconfig={
# Prevent matplotlib hook from selecting GTK/Tk backends on Linux.
"matplotlib": {"backends": "QtAgg"},
# If Gtk is pulled in indirectly, do not recurse through /usr/share/icons and themes.
"gi": {"icons": [], "themes": [], "languages": []},
},
runtime_hooks=[],
excludes=excludes,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
# Work around Windows runtime conflicts: bundled MSVCP140.dll copies from various
# packages (Qt/winrt/etc.) can cause startup/import instability in frozen builds.
# Prefer the system CRT by excluding bundled MSVCP140.dll entries.
if os.name == "nt":
def _keep_binary(entry):
for field in entry[:2]:
norm = str(field).replace("\\", "/").lower()
if norm.endswith("/msvcp140.dll") or norm.endswith("msvcp140.dll"):
return False
return True
a.binaries = a.binaries.__class__([e for e in a.binaries if _keep_binary(e)])
pyz = PYZ(
a.pure,
a.zipped_data,
cipher=block_cipher,
)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="SerialUI",
debug=False,
bootloader_ignore_signals=False,
# Stripping/UPX can corrupt some native extension dependencies
# (notably OpenBLAS/Numpy libs on Linux), causing runtime loader errors.
strip=False,
upx=False,
console=console_mode,
icon=os.path.join("assets", "icon_96.ico"),
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="SerialUI",
)