#!/usr/bin/env python3 """ Build script to create standalone executable for ESP32 Flash GUI """ import subprocess import sys import os from pathlib import Path def install_requirements(): """Install required packages""" print("Installing requirements...") subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]) def build_executable(): """Build standalone executable using PyInstaller""" print("Building standalone executable...") # PyInstaller command cmd = [ sys.executable, "-m", "PyInstaller", "--onefile", # Single executable file "--windowed", # No console window (remove if you want console) "--name", "ESP32_Flasher", "--icon", "icon.ico" if Path("icon.ico").exists() else None, "--add-data", "requirements.txt;.", # Include requirements file "gui_flasher.py" ] # Remove None values cmd = [arg for arg in cmd if arg is not None] subprocess.check_call(cmd) print("\nExecutable built successfully!") print("Find it in the 'dist' folder as 'ESP32_Flasher.exe'") def main(): os.chdir(Path(__file__).parent) try: install_requirements() build_executable() except subprocess.CalledProcessError as e: print(f"Error: {e}") sys.exit(1) if __name__ == "__main__": main()