Files
DownloadDoggo/build.py
2025-08-03 20:14:04 +02:00

51 lines
1.4 KiB
Python

import PyInstaller.__main__
import os
import shutil
import glob
def cleanup():
"""Aufräumen von temporären Build-Dateien"""
dirs_to_remove = ['build', '__pycache__']
files_to_remove = ['*.spec', '*.pyc']
for dir_name in dirs_to_remove:
if os.path.exists(dir_name):
shutil.rmtree(dir_name)
for pattern in files_to_remove:
for file in glob.glob(pattern):
try:
os.remove(file)
except:
pass # Ignoriere Fehler beim Löschen
def build():
"""Build-Prozess ausführen"""
print("Starting build process...")
# PyInstaller Optionen
options = [
'main.py', # Hauptdatei
'--name=DownloadDoggo', # Name der EXE
'--onefile', # Einzelne EXE erstellen
'--windowed', # Keine Konsole anzeigen
'--icon=icon.ico', # Icon einbinden
'--add-data=icon.ico;.', # Icon als Ressource einbinden
'--add-binary=icon.ico;.', # Icon auch als Binary einbinden
'--clean', # Cache leeren
'--noconfirm', # Vorhandene Dateien überschreiben
]
# Build ausführen
PyInstaller.__main__.run(options)
print("Build completed!")
if __name__ == "__main__":
try:
cleanup()
build()
cleanup()
print("Build successful! The EXE can be found in the 'dist' folder.")
except Exception as e:
print(f"Error during build: {str(e)}")