-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchaotics_slice.spec
More file actions
136 lines (125 loc) · 4.79 KB
/
chaotics_slice.spec
File metadata and controls
136 lines (125 loc) · 4.79 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
# -*- mode: python ; coding: utf-8 -*-
# ─────────────────────────────────────────────────────────────────────────────
# Chaotics Slice — PyInstaller spec
#
# Build:
# pyinstaller chaotics_slice.spec
#
# Output:
# dist/Slice (macOS / Linux binary)
# dist/Slice.exe (Windows)
# dist/Slice.app (macOS app bundle — one-dir mode)
# ─────────────────────────────────────────────────────────────────────────────
import sys
import os
import shutil
from pathlib import Path
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
block_cipher = None
# ── Bundle FFmpeg + FFprobe ───────────────────────────────────────────────────
# Locate the ffmpeg/ffprobe executables on the build machine's PATH and bundle
# them into the root of the app so they're available at runtime on any machine.
def find_binary(name):
exe = shutil.which(name)
if not exe:
raise RuntimeError(
f"'{name}' not found on PATH — install FFmpeg before building.\n"
f" macOS: brew install ffmpeg\n"
f" Windows: winget install Gyan.FFmpeg\n"
f" Linux: sudo apt install ffmpeg"
)
return exe
ffmpeg_bin = find_binary('ffmpeg')
ffprobe_bin = find_binary('ffprobe')
bundled_binaries = [
(ffmpeg_bin, '.'), # destination '.' = root of the bundle
(ffprobe_bin, '.'),
]
# ── Hidden imports ────────────────────────────────────────────────────────────
hidden_imports = [
'waitress',
'flask',
'werkzeug',
'jinja2',
'click',
'torch',
'torchaudio',
'wave',
'array',
'queue',
'threading',
'subprocess',
'uuid',
'json',
'pathlib',
]
hidden_imports += collect_submodules('torch')
hidden_imports += collect_submodules('flask')
hidden_imports += collect_submodules('waitress')
# ── Data files ────────────────────────────────────────────────────────────────
datas = [
('static', 'static'), # HTML / CSS / JS / assets
('silero_vad, 'silero_vad),
]
datas += collect_data_files('torch')
datas += collect_data_files('torchaudio')
# ── Analysis ──────────────────────────────────────────────────────────────────
a = Analysis(
['app.py'],
pathex=[],
binaries=bundled_binaries,
datas=datas,
hiddenimports=hidden_imports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
# Trim heavy optional deps that aren't needed
'matplotlib', 'numpy.distutils', 'IPython', 'notebook',
'scipy', 'sklearn', 'pandas', 'PIL', 'cv2',
'tkinter', 'PyQt5', 'PyQt6', 'wx',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
# ── One-file exe (Windows / Linux) ───────────────────────────────────────────
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='Slice',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True, # keep console so users can see startup logs / errors
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=None, # add 'static/res/icon.icns' / 'icon.ico' if you have one
)
# ── macOS .app bundle (one-dir, so assets live inside the bundle) ─────────────
if sys.platform == 'darwin':
app = BUNDLE(
exe,
name='Slice.app',
icon=None, # add 'static/res/icon.icns' if you have one
bundle_identifier='org.chaotics.slice',
info_plist={
'CFBundleName': 'Chaotics Slice',
'CFBundleDisplayName': 'Chaotics Slice',
'CFBundleVersion': '1.2.0',
'CFBundleShortVersionString': '1.2',
'NSHighResolutionCapable': True,
'LSUIElement': False, # show in Dock
},
)