-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathVideoSubtitleRemoverPro.spec
More file actions
117 lines (102 loc) · 3.71 KB
/
Copy pathVideoSubtitleRemoverPro.spec
File metadata and controls
117 lines (102 loc) · 3.71 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
# -*- mode: python ; coding: utf-8 -*-
import importlib.util
import os
from PyInstaller.utils.hooks import collect_data_files, collect_all
def _enabled(name):
return os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "on"}
def _available(name):
try:
return importlib.util.find_spec(name) is not None
except (ImportError, ModuleNotFoundError, ValueError):
return False
def _package_payload(entry, package):
"""Return whether a TOC entry physically belongs to an excluded package."""
destination, source, _kind = entry
package = package.lower()
destination = destination.replace('/', '\\').lower()
source = source.replace('/', '\\').lower()
return (
destination == package
or destination.startswith(package + '\\')
or ('\\site-packages\\' + package + '\\') in source
)
datas = [('backend', 'backend'), ('assets', 'assets'), ('locale', 'locale'), ('icon.png', '.'), ('icon.ico', '.')]
hiddenimports = [
'PIL._tkinter_finder', 'cv2', 'numpy', 'backend.opencv_ocr',
'tkinter', 'tkinter.ttk', 'tkinter.filedialog', 'tkinter.messagebox',
]
for package in ('rapidocr', 'rapidocr_onnxruntime'):
if _available(package):
hiddenimports.append(package)
datas += collect_data_files(package)
full_ocr = _enabled('VSR_ENABLE_FULL_OCR')
pytorch_lama = _enabled('VSR_ENABLE_PYTORCH_LAMA')
if full_ocr:
hiddenimports += [name for name in ('paddleocr', 'easyocr') if _available(name)]
if pytorch_lama and _available('simple_lama_inpainting'):
hiddenimports.append('simple_lama_inpainting')
excludes = []
if not full_ocr:
excludes += ['paddle', 'paddleocr', 'easyocr']
if not pytorch_lama:
excludes.append('simple_lama_inpainting')
if not full_ocr and not pytorch_lama:
excludes += ['torch', 'torchvision']
# numpy 2.x splits its C core into submodules (numpy._core._exceptions, ...)
# that a bare 'numpy' hiddenimport does not pull in; a partial collection makes
# the frozen exe die at launch with ModuleNotFoundError. collect_all() gathers
# the full package (data, binaries, submodules). UPX is disabled below because
# it corrupts numpy's compiled extension binaries on Windows.
np_datas, np_binaries, np_hiddenimports = collect_all('numpy')
datas += np_datas
a = Analysis(
['VideoSubtitleRemover.py'],
pathex=[],
binaries=np_binaries,
datas=datas,
hiddenimports=hiddenimports + np_hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=['assets\\runtime_hook_mp.py'],
# Default release profile is the maintainable RapidOCR/ONNX path. The
# batch build exposes explicit opt-ins for the multi-gigabyte
# PaddleOCR/EasyOCR/PyTorch fallbacks.
excludes=excludes,
noarchive=False,
optimize=0,
)
if not full_ocr and not pytorch_lama:
# Hooks for other GPU providers can discover CUDA DLLs inside torch even
# when the torch module is excluded. Keep the default RapidOCR artifact
# physically free of PyTorch so its SBOM and dependency audit match the
# selected release profile.
a.binaries = [entry for entry in a.binaries if not _package_payload(entry, 'torch')]
a.datas = [entry for entry in a.datas if not _package_payload(entry, 'torch')]
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='VideoSubtitleRemoverPro',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['icon.ico'],
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='VideoSubtitleRemoverPro',
)