-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDFtoPDFocr.spec
More file actions
138 lines (123 loc) · 3.94 KB
/
Copy pathPDFtoPDFocr.spec
File metadata and controls
138 lines (123 loc) · 3.94 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
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller spec file for PDFtoPDFocr.
Optimized build to reduce size from 285MB to ~40-60MB:
- Excludes unnecessary packages (matplotlib, numpy, pandas, scipy, etc.)
- Uses onedir mode for faster startup in MSIX containers
- Bundles Tesseract portable + Poppler binaries via --add-data
Build:
pyinstaller PDFtoPDFocr.spec
Prerequisites:
1. Clean venv with only required packages:
pip install PySide6 pytesseract Pillow pdf2image pikepdf requests
2. tesseract_portable/ folder with Tesseract OCR binaries
3. poppler/ folder with Poppler binaries (pdftoppm.exe etc.)
"""
import os
import sys
# SPECPATH wird von PyInstaller in den Spec-Namespace injiziert (Verzeichnis
# dieser .spec-Datei). Ohne diesen Eintrag findet Python build_release.py
# nicht, wenn pyinstaller aus einem anderen Arbeitsverzeichnis gestartet wird.
sys.path.insert(0, SPECPATH)
import build_release
block_cipher = None
# Tesseract und Poppler Pfade
tesseract_dir = 'tesseract_portable'
poppler_dir = 'poppler'
datas = [
('translations.json', '.'),
('assets', 'assets'),
('PDFtoPDFocr.ico', '.'),
('ICO.ico', '.'),
]
# Nur einbinden wenn vorhanden
if os.path.isdir(tesseract_dir):
# U7 Paket-Hygiene: Trainingstools/Deinstaller ausschliessen statt den
# kompletten Ordner 1:1 zu spiegeln (siehe build_release.py).
datas.extend(build_release.collect_tesseract_portable_files(tesseract_dir))
if os.path.isdir(poppler_dir):
datas.append((poppler_dir, poppler_dir))
if os.path.exists('PDFtoPDFocr.ico'):
icon_path = 'PDFtoPDFocr.ico'
elif os.path.exists('assets/icon.ico'):
icon_path = 'assets/icon.ico'
elif os.path.exists('ICO.ico'):
icon_path = 'ICO.ico'
elif os.path.exists('store_assets/icon.ico'):
icon_path = 'store_assets/icon.ico'
else:
icon_path = None
a = Analysis(
['PDFtoPDFocr_2.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=[
'sqlite3',
'PySide6.QtWidgets',
'PySide6.QtCore',
'PySide6.QtGui',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
# GUI-Frameworks, die nicht benötigt werden
'tkinter', 'PyQt5', 'PyQt6',
# Wissenschaftliche & schwere Pakete
'matplotlib', 'numpy', 'pandas', 'scipy', 'sklearn',
'altair', 'plotly', 'pyarrow', 'soundfile', 'sympy',
# Andere nicht benötigte Pakete
'cv2', 'docx', 'openpyxl', 'xlrd',
'IPython', 'jupyter', 'notebook',
'pytest', 'unittest',
'setuptools', 'pip', 'wheel',
'cryptography', 'paramiko',
'asyncio', 'aiohttp',
# PySide6-Module, die nicht benötigt werden
'PySide6.QtWebEngine', 'PySide6.QtWebEngineWidgets',
'PySide6.QtMultimedia', 'PySide6.QtMultimediaWidgets',
'PySide6.Qt3DCore', 'PySide6.Qt3DRender',
'PySide6.QtCharts', 'PySide6.QtDataVisualization',
'PySide6.QtNetwork', 'PySide6.QtBluetooth',
'PySide6.QtPositioning', 'PySide6.QtSensors',
'PySide6.QtSerialPort', 'PySide6.QtSvg',
'PySide6.QtTest', 'PySide6.QtXml',
'PySide6.QtDesigner', 'PySide6.QtHelp',
'PySide6.QtOpenGL', 'PySide6.QtOpenGLWidgets',
'PySide6.QtPdf', 'PySide6.QtPdfWidgets',
'PySide6.QtQuick', 'PySide6.QtQml',
],
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='PDFtoPDFocr',
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_path,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='PDFtoPDFocr',
)