Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

build: fetch pip-only deps with uv into a per-user venv

public

build: fetch pip-only deps with uv into a per-user venv

fsrs is not in the Arch repos or the AUR. schach.sh creates
~/.local/share/schach/venv with --system-site-packages (gi, chess,
onnxruntime stay system packages) and installs requirements.txt via
uv; reinstalls when the file changes. Per user, so every account gets
its own. Falls back to system python3 without uv or network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changeset469217abc78396765517bce5ea6ef23ee5c0129e
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents63e835c7a558
Children7726f8369605
Pushlog
by timo via ssh
by timo via ssh

modified README.md +8 −1

@@ -108,6 +108,11 @@ Abhängigkeiten: `python-gobject`, `libadwaita`, `librsvg`, `python-chess`,
108108
 andere onnxruntime-Variante), `python-numpy`. Optional `python-psutil`: erkennt den Akkubetrieb
109109
 (Linux, Windows, macOS) für den Energiesparmodus; ohne gilt der Rechner als am Netz.
110110
 
111
+Was es nicht in den Paketquellen gibt, steht in `requirements.txt` (zurzeit `fsrs` für die
112
+Wiederholung). `schach.sh` holt es mit [uv](https://docs.astral.sh/uv/) beim ersten Start in
113
+ein venv pro Benutzer (`~/.local/share/schach/venv`), das die Systempakete mitbenutzt, und
114
+erneuert es, wenn sich `requirements.txt` ändert.
115
+
111116
 Maia-3 läuft über ONNX Runtime statt PyTorch (`schach/maia_onnx.py`). Das Modell (ONNX-Export
112117
 von Maia3-79M mit Zughistorie, `bqrio/maia3-onnx`, 156 MB, per Prüfsumme festgelegt) lädt
113118
 beim ersten Start; die Titelleiste zeigt den Fortschritt, ein abgebrochener Download wird
@@ -120,7 +125,9 @@ Optional für „PDF über LaTeX“: `texlive-games` (`xskak`) und `pdflatex`.
120125
 
121126
 Tests:
122127
 
123
-    python -m unittest discover -s tests -t .
128
+    ~/.local/share/schach/venv/bin/python -m unittest discover -s tests -t .
129
+
130
+(das venv legt `schach.sh` beim ersten Start an)
124131
 
125132
 Ins App-Menü aufnehmen:
126133
 

added requirements.txt +3 −0

@@ -0,0 +1,3 @@
1
+# Python-Pakete, die es nicht in den Paketquellen gibt. schach.sh holt sie per uv in ein
2
+# venv pro Benutzer (~/.local/share/schach/venv), das die Systempakete mitbenutzt.
3
+fsrs==6.3.3

modified schach.sh +19 −1

@@ -2,4 +2,22 @@
22
 # GTKs Vulkan-Renderer meldet auf manchen Treibern harmlose VK_SUBOPTIMAL_KHR-Warnungen;
33
 # der OpenGL-Renderer (gl) zeichnet gleich gut und bleibt still. Überschreibbar per GSK_RENDERER.
44
 export GSK_RENDERER="${GSK_RENDERER:-gl}"
5
-cd "$(dirname "$(readlink -f "$0")")" && exec python3 -m schach "$@"
5
+cd "$(dirname "$(readlink -f "$0")")" || exit 1
6
+
7
+# Pakete aus requirements.txt (nicht in den Paketquellen) liegen in einem venv pro Benutzer,
8
+# das die Systempakete (gi, chess, onnxruntime …) mitbenutzt. uv legt es beim ersten Start an
9
+# und erneuert es, wenn sich requirements.txt ändert.
10
+VENV="${XDG_DATA_HOME:-$HOME/.local/share}/schach/venv"
11
+if ! cmp -s requirements.txt "$VENV/requirements.txt" 2>/dev/null; then
12
+    if command -v uv >/dev/null 2>&1 \
13
+        && uv venv --quiet --allow-existing --system-site-packages --python /usr/bin/python3 "$VENV" \
14
+        && uv pip install --quiet --python "$VENV/bin/python" -r requirements.txt; then
15
+        cp requirements.txt "$VENV/requirements.txt"
16
+    else
17
+        echo "schach: Konnte die Pakete aus requirements.txt nicht einrichten (uv fehlt oder kein Netz)." >&2
18
+    fi
19
+fi
20
+if [ -x "$VENV/bin/python" ]; then
21
+    exec "$VENV/bin/python" -m schach "$@"
22
+fi
23
+exec python3 -m schach "$@"