Skip to content

Commit baf69f8

Browse files
authored
Update Main.spec(Windows)
1 parent 195ac58 commit baf69f8

1 file changed

Lines changed: 54 additions & 25 deletions

File tree

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- mode: python ; coding: utf-8 -*-
22
from PyInstaller.utils.hooks import collect_all, copy_metadata
33
import os
4+
import xgboost
45

56
block_cipher = None
67

@@ -9,41 +10,57 @@ binaries = []
910
hiddenimports = []
1011

1112
# Add necessary metadata
12-
datas += copy_metadata('transformers')
13-
datas += copy_metadata('tokenizers')
14-
datas += copy_metadata('filelock')
15-
datas += copy_metadata('requests')
16-
datas += copy_metadata('packaging')
17-
datas += copy_metadata('regex')
18-
datas += copy_metadata('tqdm')
19-
datas += copy_metadata('numpy')
20-
datas += copy_metadata('torch')
21-
datas += copy_metadata('pandas')
22-
datas += copy_metadata('yfinance')
23-
datas += copy_metadata('PyQt6')
24-
datas += copy_metadata('matplotlib')
25-
datas += copy_metadata('scikit-learn')
26-
datas += copy_metadata('joblib')
13+
packages_to_copy = [
14+
'transformers', 'tokenizers', 'filelock', 'requests', 'packaging',
15+
'regex', 'tqdm', 'numpy', 'torch', 'pandas', 'yfinance', 'matplotlib',
16+
'scikit-learn', 'xgboost', 'ta', 'PyQt6', 'beautifulsoup4', 'langdetect',
17+
'scipy'
18+
]
2719

28-
# Collect all necessary files for transformers
29-
datas_t, binaries_t, hiddenimports_t = collect_all('transformers')
30-
datas += datas_t
31-
binaries += binaries_t
32-
hiddenimports += hiddenimports_t
20+
for package in packages_to_copy:
21+
try:
22+
datas += copy_metadata(package)
23+
except Exception as e:
24+
print(f"Failed to copy metadata for {package}: {e}")
25+
26+
# Collect all necessary files for critical packages
27+
for package in ['transformers', 'torch', 'sklearn', 'ta', 'scipy', 'xgboost']:
28+
datas_t, binaries_t, hiddenimports_t = collect_all(package)
29+
datas += datas_t
30+
binaries += binaries_t
31+
hiddenimports += hiddenimports_t
3332

3433
# Add ipadic data files
3534
import ipadic
3635
ipadic_dir = os.path.dirname(ipadic.__file__)
3736
datas += [(ipadic_dir, 'ipadic')]
3837

38+
# Add XGBoost DLL
39+
xgboost_dir = os.path.dirname(xgboost.__file__)
40+
xgboost_lib = os.path.join(xgboost_dir, 'lib', 'xgboost.dll')
41+
if os.path.exists(xgboost_lib):
42+
binaries.append((xgboost_lib, '.'))
43+
else:
44+
print(f"Warning: XGBoost DLL not found at {xgboost_lib}")
45+
3946
a = Analysis(
4047
['Main.py'],
4148
pathex=[],
4249
binaries=binaries,
4350
datas=datas,
44-
hiddenimports=['transformers', 'tqdm', 'regex', 'requests', 'packaging', 'filelock', 'numpy', 'tokenizers',
45-
'torch', 'ipadic', 'pandas', 'yfinance', 'PyQt6', 'matplotlib', 'scikit-learn', 'joblib',
46-
'bs4', 'langdetect', 'ta'] + hiddenimports,
51+
hiddenimports=[
52+
'transformers', 'tqdm', 'regex', 'requests', 'packaging', 'filelock',
53+
'numpy', 'tokenizers', 'torch', 'ipadic', 'PyQt6', 'bs4', 'langdetect',
54+
'yfinance', 'pandas', 'matplotlib', 'sklearn', 'xgboost', 'ta',
55+
'datetime', 'json', 're', 'time', 'atexit', 'tempfile',
56+
'PyQt6.QtWidgets', 'PyQt6.QtGui', 'PyQt6.QtCore', 'PyQt6.sip',
57+
'matplotlib.backends.backend_qt6agg',
58+
'sklearn.model_selection', 'sklearn.preprocessing', 'sklearn.ensemble',
59+
'sklearn.metrics', 'sklearn.neural_network',
60+
'ta.momentum', 'ta.trend', 'ta.volatility', 'ta.volume',
61+
'scipy', 'scipy.sparse', 'scipy._lib', 'scipy._lib.array_api_compat',
62+
'scipy._lib.array_api_compat.numpy', 'scipy._lib.array_api_compat.numpy.fft'
63+
] + hiddenimports,
4764
hookspath=[],
4865
hooksconfig={},
4966
runtime_hooks=[],
@@ -53,16 +70,28 @@ a = Analysis(
5370
cipher=block_cipher,
5471
noarchive=False,
5572
)
73+
5674
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
5775

76+
# Icon path (change this to the correct path of your icon file)
77+
icon_path = r'C:\Users\ka1t0\Documents\Magi\NERV.ico'
78+
79+
# Check if the icon file exists
80+
if os.path.exists(icon_path):
81+
icon_option = {'icon': icon_path}
82+
print(f"Using icon: {icon_path}")
83+
else:
84+
icon_option = {}
85+
print(f"Warning: Icon file not found at {icon_path}. Building without an icon.")
86+
5887
exe = EXE(
5988
pyz,
6089
a.scripts,
6190
a.binaries,
6291
a.zipfiles,
6392
a.datas,
6493
[],
65-
name='Magi',
94+
name='Magi', # Changed to 'Magi' as per your request
6695
debug=False,
6796
bootloader_ignore_signals=False,
6897
strip=False,
@@ -75,5 +104,5 @@ exe = EXE(
75104
target_arch=None,
76105
codesign_identity=None,
77106
entitlements_file=None,
78-
icon='C:/Users/ka1t0/Documents/Magi/Magi.ico', # Make sure there's a closing quote here
107+
**icon_option
79108
)

0 commit comments

Comments
 (0)