47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import os
|
|
from PIL import Image
|
|
import PyInstaller.__main__
|
|
import PyQt5
|
|
|
|
# Paths
|
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
MAIN_SCRIPT = os.path.join(ROOT_DIR, "main.py")
|
|
STYLING_DIR = os.path.join(ROOT_DIR, "styling")
|
|
|
|
# Icon paths
|
|
PNG_ICON = os.path.join(STYLING_DIR, "logo.png")
|
|
ICO_ICON = os.path.join(STYLING_DIR, "logo.ico")
|
|
|
|
# Convert PNG to ICO
|
|
img = Image.open(PNG_ICON)
|
|
img.save(ICO_ICON, format="ICO", sizes=[(256,256), (128,128), (64,64), (32,32), (16,16)])
|
|
print(f"Converted {PNG_ICON} to {ICO_ICON}")
|
|
|
|
# Detect PyQt5 platforms folder automatically
|
|
pyqt_dir = os.path.dirname(PyQt5.__file__)
|
|
platforms_path = None
|
|
|
|
# Walk recursively to find the 'platforms' folder
|
|
for root, dirs, files in os.walk(pyqt_dir):
|
|
if 'platforms' in dirs:
|
|
platforms_path = os.path.join(root, 'platforms')
|
|
break
|
|
|
|
if platforms_path is None or not os.path.exists(platforms_path):
|
|
raise FileNotFoundError(f"Could not locate PyQt5 'platforms' folder under {pyqt_dir}")
|
|
|
|
print(f"Using PyQt5 platforms folder: {platforms_path}")
|
|
|
|
# Build EXE with PyInstaller
|
|
PyInstaller.__main__.run([
|
|
MAIN_SCRIPT,
|
|
'--noconfirm',
|
|
'--onefile',
|
|
'--windowed',
|
|
f'--icon={ICO_ICON}',
|
|
# Only include the platforms folder (minimal requirement for PyQt5)
|
|
'--add-data', f'{platforms_path};PyQt5/Qt/plugins/platforms',
|
|
])
|
|
|
|
print("Build complete! Check the 'dist' folder for the executable.")
|