MAC-START.md aktualisiert: Repo ist oeffentlich (kein Login), neuer Abschnitt 10 "Projekt uebernehmen" (Struktur, Tests, Selbsttest, Branch/Fork-Workflow), Footer an Public-Repo angepasst.
This commit is contained in:
1 parent
37aa5c25f6
commit
a088c23a09
3 files changed
+324
-18
No files matched your search
@@ -1,44 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
# Startet das Habegger Loader Game.
|
||||
# Startet das Habegger Loader Game auf macOS und Linux.
|
||||
#
|
||||
# Beim ersten Start wird eine lokale virtuelle Umgebung (.venv) angelegt und
|
||||
# requirements.txt installiert. Ändert sich requirements.txt, wird neu
|
||||
# installiert. Alle Argumente werden an main.py weitergegeben, z. B.:
|
||||
# requirements.txt installiert. Ändert sich requirements.txt oder das Python,
|
||||
# wird neu installiert bzw. die Umgebung neu gebaut. Alles Weitere siehe
|
||||
# MAC-START.md.
|
||||
#
|
||||
# ./run.sh --windowed
|
||||
# ./run.sh --name "Anna" --seed 42
|
||||
#
|
||||
# Getestet auf macOS (arm64) und Linux.
|
||||
# ./run.sh # Fenster
|
||||
# ./run.sh --fullscreen # Vollbild (Eventbetrieb)
|
||||
# ./run.sh --smoke 10 # Selbsttest ohne Eingabegeräte
|
||||
# PYTHON=python3.12 ./run.sh # bestimmtes Python erzwingen
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
VENV=".venv"
|
||||
PYTHON="${PYTHON:-python3}"
|
||||
STAMP="$VENV/.requirements.sha256"
|
||||
REQ_STAMP="$VENV/.requirements.sha256"
|
||||
PY_STAMP="$VENV/.python-version"
|
||||
|
||||
if [ ! -x "$VENV/bin/python" ]; then
|
||||
echo "→ Lege virtuelle Umgebung an ($("$PYTHON" --version 2>&1))"
|
||||
"$PYTHON" -m venv "$VENV"
|
||||
# --------------------------------------------------------------------------
|
||||
# 1. Passendes Python finden (neueste zuerst, 3.12 ist die sichere Wahl für
|
||||
# pygame-Wheels; das alte python3 aus den Xcode-Tools bleibt aussen vor)
|
||||
# --------------------------------------------------------------------------
|
||||
if [ -z "${PYTHON:-}" ]; then
|
||||
for candidate in python3.12 python3.13 python3.11 python3.10 python3.9 python3; do
|
||||
if command -v "$candidate" >/dev/null 2>&1; then
|
||||
PYTHON="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -z "${PYTHON:-}" ]; then
|
||||
echo "✗ Kein Python gefunden."
|
||||
echo " Installiere Python 3.12: brew install python@3.12"
|
||||
echo " (Details siehe MAC-START.md)"
|
||||
exit 1
|
||||
fi
|
||||
PY_VERSION="$("$PYTHON" -V 2>&1)"
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 2. Virtuelle Umgebung anlegen bzw. erneuern
|
||||
# --------------------------------------------------------------------------
|
||||
if [ -d "$VENV" ] && [ -f "$PY_STAMP" ] && [ "$(cat "$PY_STAMP")" != "$PY_VERSION" ]; then
|
||||
echo "→ Python hat sich geändert ($(cat "$PY_STAMP") → $PY_VERSION) – .venv wird neu angelegt"
|
||||
rm -rf "$VENV"
|
||||
fi
|
||||
|
||||
if [ ! -x "$VENV/bin/python" ]; then
|
||||
echo "→ Lege virtuelle Umgebung an ($PY_VERSION)"
|
||||
"$PYTHON" -m venv "$VENV"
|
||||
fi
|
||||
echo "$PY_VERSION" >"$PY_STAMP"
|
||||
|
||||
if ! "$VENV/bin/python" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 9) else 1)'; then
|
||||
echo "✗ Python 3.9 oder neuer wird benötigt (gefunden: $("$VENV/bin/python" -V 2>&1))"
|
||||
echo " Tipp: neueres Python installieren (z.B. brew install python@3.12) und"
|
||||
echo " die Umgebung neu anlegen: rm -rf .venv"
|
||||
echo "✗ Python 3.9 oder neuer wird benötigt (gefunden: $PY_VERSION)"
|
||||
echo " Tipp: brew install python@3.12, danach: rm -rf .venv"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 3. Abhängigkeiten installieren (nur wenn sich requirements.txt geändert hat)
|
||||
# --------------------------------------------------------------------------
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
REQ_HASH="$(shasum -a 256 requirements.txt | cut -d' ' -f1)"
|
||||
else
|
||||
REQ_HASH="$(sha256sum requirements.txt | cut -d' ' -f1)"
|
||||
fi
|
||||
|
||||
if [ ! -f "$STAMP" ] || [ "$(cat "$STAMP")" != "$REQ_HASH" ]; then
|
||||
if [ ! -f "$REQ_STAMP" ] || [ "$(cat "$REQ_STAMP")" != "$REQ_HASH" ]; then
|
||||
echo "→ Installiere Abhängigkeiten aus requirements.txt"
|
||||
"$VENV/bin/python" -m pip install --quiet --upgrade pip
|
||||
"$VENV/bin/python" -m pip install --quiet -r requirements.txt
|
||||
echo "$REQ_HASH" >"$STAMP"
|
||||
echo "$REQ_HASH" >"$REQ_STAMP"
|
||||
fi
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 4. Spiel starten (alle Argumente werden weitergegeben)
|
||||
# --------------------------------------------------------------------------
|
||||
exec "$VENV/bin/python" main.py "$@"
|
||||
Reference in new issue
Block a user