Files
hms-mediaengine/_entwicklung/make_mac_app.py
T
HMS MediaEngine Agent 362e089be0 AUFGERAUMT: Root auf 10 sichtbare Elemente reduziert
Der Nutzer hat recht: Der Ordner war voller Entwicklungs-Muell.
Jetzt ist sauber getrennt:

ROOT (was der Nutzer sieht und braucht):
- run.py                     = das Programm
- hms_app/                   = der Anwendungscode
- HMS MediaEngine.app        = macOS Doppelklick-Starter
- HMS-Start.vbs              = Windows Doppelklick-Starter
- HMS-Install.vbs             = Windows Erst-Installation
- HMS-Mac-Install.command     = macOS Homebrew-Installation
- HMS-Portable-Install.command = macOS Portable-Installation (16GB-Fix)
- installer_gui.py           = grafischer Installer
- launcher.pyw + launcher_core.py = interne Start-Logik
- LIESMICH.txt               = 10-Zeilen-Kurzanleitung
- .gitignore

_entwicklung/ (alles andere, NICHT benoetigt):
- packages/ apps/ native/ plugins/ tools/ schemas/ tests/ docs/
  build/ fixture_profiles/
- PLAN.md STATUS.md ERRORS.md TEST_REPORT.md CHANGELOG.md README.md
- pyproject.toml uv.lock setup_*.sh/ps1 make_mac_app.py

Diese Trennung gilt ab sofort fuer alle Commits. Der Nutzer kann
_entwicklung/ loeschen wenn er Platz braucht - die App laeuft ohne.

Verifiziert: App startet nach Aufraeumen unveraendert (Health 200).
2026-09-11 23:44:06 +02:00

82 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Erzeugt 'HMS MediaEngine.app' im Projektordner (macOS App-Bundle).
Aufruf: python3 make_mac_app.py
Danach: 'HMS MediaEngine.app' per Doppelklick im Finder starten.
Der Launcher prueft unsichtbar: fehlt GStreamer, oeffnet sich der
grafische Installer; ist alles da, startet die Engine im Hintergrund
und der Browser oeffnet sich.
"""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parent
APP = ROOT / "HMS MediaEngine.app"
INFO_PLIST = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>HMS MediaEngine</string>
<key>CFBundleDisplayName</key><string>HMS MediaEngine</string>
<key>CFBundleIdentifier</key><string>de.hms.mediaengine</string>
<key>CFBundleVersion</key><string>0.1.0</string>
<key>CFBundleShortVersionString</key><string>0.1.0</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleExecutable</key><string>HMS-Launcher</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>NSHighResolutionCapable</key><true/>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
</dict>
</plist>
"""
LAUNCHER = r'''#!/bin/bash
# HMS MediaEngine App-Start (vom Finder, ohne sichtbares Terminal)
DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
PY=""
for p in /opt/homebrew/bin/python3 /usr/local/bin/python3 python3; do
if command -v "$p" >/dev/null 2>&1; then PY="$p"; break; fi
done
if [ -z "$PY" ]; then
osascript -e 'display alert "Python nicht gefunden" message "Bitte HMS-Mac-Install.command im Projektordner einmal ausfuehren - es installiert alles Grafische." as critical' >/dev/null 2>&1
exit 1
fi
cd "$DIR"
# Portable GStreamer-Umgebung laden (falls HMS-Portable-Install genutzt)
if [ -f "$DIR/runtime/env.sh" ]; then
source "$DIR/runtime/env.sh"
fi
if "$PY" -c "import gi; gi.require_version('Gst','1.0')" >/dev/null 2>&1; then
nohup "$PY" "$DIR/run.py" >>/tmp/hms-mediaengine.log 2>&1 &
PORT=8080
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; do
curl -s -o /dev/null "http://localhost:$PORT/api/health" && break
sleep 0.5
done
open "http://localhost:$PORT"
exit 0
else
nohup "$PY" "$DIR/installer_gui.py" >/tmp/hms-installer.log 2>&1 &
exit 0
fi
'''
def build() -> None:
macos = APP / "Contents" / "MacOS"
macos.mkdir(parents=True, exist_ok=True)
(APP / "Contents" / "Info.plist").write_text(INFO_PLIST, "utf-8")
launcher = macos / "HMS-Launcher"
launcher.write_text(LAUNCHER, "utf-8")
launcher.chmod(0o755)
print(f"App erstellt: {APP}")
print("Doppelklick im Finder: 'HMS MediaEngine.app'")
if __name__ == "__main__":
build()