35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
|
|
import os
|
||
|
|
import platform
|
||
|
|
import subprocess
|
||
|
|
import shutil
|
||
|
|
|
||
|
|
def build():
|
||
|
|
# Prüfen, ob PyInstaller auf dem System verfügbar ist
|
||
|
|
if not shutil.which("pyinstaller"):
|
||
|
|
print("FEHLER: PyInstaller wurde nicht gefunden!")
|
||
|
|
print("Bitte installiere es im Terminal mit: sudo apt-get install pyinstaller")
|
||
|
|
return
|
||
|
|
|
||
|
|
# Windows benutzt ein Semikolon, Linux/Mac einen Doppelpunkt für Pfade
|
||
|
|
separator = ";" if platform.system() == "Windows" else ":"
|
||
|
|
|
||
|
|
cmd = [
|
||
|
|
"pyinstaller",
|
||
|
|
"--name", "Yahtzee",
|
||
|
|
"--onefile", # Packt alles in EINE einzige ausführbare Datei
|
||
|
|
"--windowed", # Versteckt die Konsole (wichtig für GUI Apps)
|
||
|
|
"--add-data", f"ressources{separator}ressources", # Packt alle Bilder direkt ins Programm!
|
||
|
|
"main.py"
|
||
|
|
]
|
||
|
|
|
||
|
|
print(f"\nStarte Build-Prozess für {platform.system()}...")
|
||
|
|
subprocess.run(cmd)
|
||
|
|
|
||
|
|
print("\n=============================================")
|
||
|
|
print("Build erfolgreich abgeschlossen!")
|
||
|
|
print("Du findest deine fertige ausführbare Datei im Ordner 'dist'.")
|
||
|
|
print("=============================================")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
build()
|