65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
"""
|
|
Script to build Windows executable using PyInstaller
|
|
Run this on a Windows machine or use Wine on Linux
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
def build_executable():
|
|
"""Build the Windows executable"""
|
|
|
|
print("Building Windows executable with PyInstaller...")
|
|
print("Note: For best results, build on a Windows machine")
|
|
print()
|
|
|
|
# Check if icon file exists
|
|
icon_param = []
|
|
if os.path.exists('app_icon.ico'):
|
|
icon_param = ['--icon=app_icon.ico']
|
|
print("Using icon file: app_icon.ico")
|
|
else:
|
|
print("No icon file found (optional)")
|
|
|
|
# PyInstaller command - simplified to avoid module collection issues
|
|
cmd = [
|
|
'pyinstaller',
|
|
'--name=DatabaseApp',
|
|
'--onefile',
|
|
'--windowed',
|
|
'--hidden-import=mysql.connector',
|
|
'--hidden-import=kivy.core.window.window_sdl2',
|
|
'--hidden-import=win32timezone',
|
|
'--exclude-module=_tkinter',
|
|
'--exclude-module=matplotlib',
|
|
'--exclude-module=numpy',
|
|
] + icon_param + ['main.py']
|
|
|
|
try:
|
|
print("Running PyInstaller...")
|
|
print("Command:", ' '.join(cmd))
|
|
print()
|
|
subprocess.run(cmd, check=True)
|
|
print("\n" + "="*50)
|
|
print("Build completed successfully!")
|
|
print("Executable location: dist/DatabaseApp.exe")
|
|
print("="*50)
|
|
print("\nNote: If the executable doesn't work on Windows:")
|
|
print("1. Build it directly on a Windows machine")
|
|
print("2. Use the DatabaseApp.spec file: pyinstaller DatabaseApp.spec")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"\nError building executable: {e}")
|
|
print("\nTroubleshooting:")
|
|
print("1. Make sure you're building on Windows for best compatibility")
|
|
print("2. Try using the spec file: pyinstaller DatabaseApp.spec")
|
|
print("3. Check BUILD_WINDOWS_GUIDE.md for more information")
|
|
sys.exit(1)
|
|
except FileNotFoundError:
|
|
print("PyInstaller not found. Please install it first:")
|
|
print("pip install pyinstaller")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
build_executable()
|