Skip to content

Commit

Permalink
Update Main.spec(Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
SU2H1 authored Jul 12, 2024
1 parent 195ac58 commit baf69f8
Showing 1 changed file with 54 additions and 25 deletions.
79 changes: 54 additions & 25 deletions Magi/Beta Version 1.1/Main.spec(Windows)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all, copy_metadata
import os
import xgboost

block_cipher = None

Expand All @@ -9,41 +10,57 @@ binaries = []
hiddenimports = []

# Add necessary metadata
datas += copy_metadata('transformers')
datas += copy_metadata('tokenizers')
datas += copy_metadata('filelock')
datas += copy_metadata('requests')
datas += copy_metadata('packaging')
datas += copy_metadata('regex')
datas += copy_metadata('tqdm')
datas += copy_metadata('numpy')
datas += copy_metadata('torch')
datas += copy_metadata('pandas')
datas += copy_metadata('yfinance')
datas += copy_metadata('PyQt6')
datas += copy_metadata('matplotlib')
datas += copy_metadata('scikit-learn')
datas += copy_metadata('joblib')
packages_to_copy = [
'transformers', 'tokenizers', 'filelock', 'requests', 'packaging',
'regex', 'tqdm', 'numpy', 'torch', 'pandas', 'yfinance', 'matplotlib',
'scikit-learn', 'xgboost', 'ta', 'PyQt6', 'beautifulsoup4', 'langdetect',
'scipy'
]

# Collect all necessary files for transformers
datas_t, binaries_t, hiddenimports_t = collect_all('transformers')
datas += datas_t
binaries += binaries_t
hiddenimports += hiddenimports_t
for package in packages_to_copy:
try:
datas += copy_metadata(package)
except Exception as e:
print(f"Failed to copy metadata for {package}: {e}")

# Collect all necessary files for critical packages
for package in ['transformers', 'torch', 'sklearn', 'ta', 'scipy', 'xgboost']:
datas_t, binaries_t, hiddenimports_t = collect_all(package)
datas += datas_t
binaries += binaries_t
hiddenimports += hiddenimports_t

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

# Add XGBoost DLL
xgboost_dir = os.path.dirname(xgboost.__file__)
xgboost_lib = os.path.join(xgboost_dir, 'lib', 'xgboost.dll')
if os.path.exists(xgboost_lib):
binaries.append((xgboost_lib, '.'))
else:
print(f"Warning: XGBoost DLL not found at {xgboost_lib}")

a = Analysis(
['Main.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=['transformers', 'tqdm', 'regex', 'requests', 'packaging', 'filelock', 'numpy', 'tokenizers',
'torch', 'ipadic', 'pandas', 'yfinance', 'PyQt6', 'matplotlib', 'scikit-learn', 'joblib',
'bs4', 'langdetect', 'ta'] + hiddenimports,
hiddenimports=[
'transformers', 'tqdm', 'regex', 'requests', 'packaging', 'filelock',
'numpy', 'tokenizers', 'torch', 'ipadic', 'PyQt6', 'bs4', 'langdetect',
'yfinance', 'pandas', 'matplotlib', 'sklearn', 'xgboost', 'ta',
'datetime', 'json', 're', 'time', 'atexit', 'tempfile',
'PyQt6.QtWidgets', 'PyQt6.QtGui', 'PyQt6.QtCore', 'PyQt6.sip',
'matplotlib.backends.backend_qt6agg',
'sklearn.model_selection', 'sklearn.preprocessing', 'sklearn.ensemble',
'sklearn.metrics', 'sklearn.neural_network',
'ta.momentum', 'ta.trend', 'ta.volatility', 'ta.volume',
'scipy', 'scipy.sparse', 'scipy._lib', 'scipy._lib.array_api_compat',
'scipy._lib.array_api_compat.numpy', 'scipy._lib.array_api_compat.numpy.fft'
] + hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand All @@ -53,16 +70,28 @@ a = Analysis(
cipher=block_cipher,
noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

# Icon path (change this to the correct path of your icon file)
icon_path = r'C:\Users\ka1t0\Documents\Magi\NERV.ico'

# Check if the icon file exists
if os.path.exists(icon_path):
icon_option = {'icon': icon_path}
print(f"Using icon: {icon_path}")
else:
icon_option = {}
print(f"Warning: Icon file not found at {icon_path}. Building without an icon.")

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='Magi',
name='Magi', # Changed to 'Magi' as per your request
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand All @@ -75,5 +104,5 @@ exe = EXE(
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='C:/Users/ka1t0/Documents/Magi/Magi.ico', # Make sure there's a closing quote here
**icon_option
)

0 comments on commit baf69f8

Please sign in to comment.