-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook-mymodules.py
More file actions
64 lines (53 loc) · 1.2 KB
/
Copy pathhook-mymodules.py
File metadata and controls
64 lines (53 loc) · 1.2 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
# hook-mymodules.py
# This helps PyInstaller find hidden modules
from PyInstaller.utils.hooks import collect_all, collect_submodules
# Common problematic packages
datas, binaries, hiddenimports = [], [], []
# Try to include common data science/ML packages
try:
import pandas
datas += collect_all('pandas')
hiddenimports += collect_submodules('pandas')
except:
pass
try:
import numpy
datas += collect_all('numpy')
except:
pass
try:
import matplotlib
datas += collect_all('matplotlib')
except:
pass
try:
import sklearn
hiddenimports += collect_submodules('sklearn')
except:
pass
try:
import openpyxl
hiddenimports += collect_submodules('openpyxl')
except:
pass
# GUI frameworks
for gui in ['PyQt5', 'PySide6', 'tkinter', 'customtkinter']:
try:
__import__(gui)
hiddenimports.append(gui)
except:
pass
# Common data modules
common_modules = [
'xlsxwriter', 'xlrd', 'xlwt',
'PIL', 'pillow',
'json', 'csv', 'sqlite3',
'requests', 'urllib3',
'logging', 'threading', 'multiprocessing'
]
for mod in common_modules:
try:
__import__(mod)
hiddenimports.append(mod)
except:
pass