songsplit heißt jetzt unmix: Submodul tools/unmix auf 58ff3fe, Skript, Make-Ziele, Paket, Doku (#1080)
Das Repository wlkns-dev/unmix hat Werkzeug, Paket und Befehl umbenannt (songsplit bleibt dort als Alias). Die Spezifikation ist unverändert. Umgebungsvariablen UNMIX_SRC und UNMIX_VENV, Paket-Befehl singtrainer-unmix, Pfad /usr/share/singtrainer/unmix, Testdaten-Manifest aus dem neuen Beispiel. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Submodule tools/songsplit deleted from 7bbc6b78df
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Startet das Analysewerkzeug `songsplit` (Songs in Songpacks zerlegen). Das Werkzeug liegt als Git-Submodul unter
|
||||
# tools/songsplit, im Paket unter /usr/share/singtrainer/songsplit; dieses Skript gibt es als tools/songsplit.sh und im
|
||||
# Paket als /usr/bin/singtrainer-songsplit.
|
||||
#
|
||||
# songsplit.sh setup [--yes] einmalig: Python-Umgebung und Abhängigkeiten anlegen (lädt mehrere GB, fragt vorher)
|
||||
# songsplit.sh doctor System- und Hardwareprüfung von songsplit
|
||||
# songsplit.sh analyze <audio> -o <ordner> [--lang de] alles andere geht an `songsplit` weiter
|
||||
#
|
||||
# Die Umgebung liegt in $SONGSPLIT_VENV (Standard: ~/.local/share/singtrainer/songsplit-venv), der Quellordner in
|
||||
# $SONGSPLIT_SRC (Standard: das Submodul neben diesem Skript oder das Paket). Die Einrichtung (`setup`) ist nicht getestet,
|
||||
# weil sie große Downloads macht; alles andere ist in tools/test_songsplit_wrapper.py geprüft.
|
||||
set -eu
|
||||
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
src="${SONGSPLIT_SRC:-}"
|
||||
if [ -z "$src" ]; then
|
||||
for c in "$here/songsplit" /usr/share/singtrainer/songsplit; do
|
||||
if [ -f "$c/pyproject.toml" ]; then src="$c"; break; fi
|
||||
done
|
||||
fi
|
||||
if [ -z "$src" ] || [ ! -f "$src/pyproject.toml" ]; then
|
||||
echo "songsplit nicht gefunden. Im Repository: git submodule update --init tools/songsplit" >&2
|
||||
echo "(oder SONGSPLIT_SRC auf den Ordner setzen, der pyproject.toml enthält)." >&2
|
||||
exit 1
|
||||
fi
|
||||
venv="${SONGSPLIT_VENV:-${XDG_DATA_HOME:-$HOME/.local/share}/singtrainer/songsplit-venv}"
|
||||
|
||||
cmd="${1:-}"
|
||||
if [ "$cmd" = "setup" ]; then
|
||||
shift
|
||||
yes=0
|
||||
[ "${1:-}" = "--yes" ] && yes=1
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "uv fehlt (Python-Paketverwaltung). Arch: sudo pacman -S uv" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "songsplit einrichten:"
|
||||
echo " Quelle: $src"
|
||||
echo " Umgebung: $venv"
|
||||
echo "Das lädt Python 3.12 (falls nicht vorhanden), torch, demucs, whisper und weitere Pakete aus dem Netz"
|
||||
echo "(mehrere GB); die Modelle folgen beim ersten Analyse-Lauf."
|
||||
if [ "$yes" -ne 1 ]; then
|
||||
printf "Fortfahren? [j/N] "
|
||||
read -r answer || answer=""
|
||||
case "$answer" in j|J|y|Y) ;; *) echo "Abgebrochen."; exit 1 ;; esac
|
||||
fi
|
||||
mkdir -p "$(dirname "$venv")"
|
||||
UV_PROJECT_ENVIRONMENT="$venv" exec uv sync --project "$src" --frozen --no-dev --no-editable --python 3.12
|
||||
fi
|
||||
|
||||
if [ ! -x "$venv/bin/songsplit" ]; then
|
||||
echo "songsplit ist noch nicht eingerichtet (kein $venv/bin/songsplit)." >&2
|
||||
echo "Einmalig ausführen: $0 setup" >&2
|
||||
exit 1
|
||||
fi
|
||||
exec "$venv/bin/songsplit" "$@"
|
||||
@ -1,4 +1,4 @@
|
||||
"""Tests für tools/songsplit.sh ohne echte Python-Umgebung: Attrappen für `uv` und `songsplit`, eigene Ordner."""
|
||||
"""Tests für tools/unmix.sh ohne echte Python-Umgebung: Attrappen für `uv` und `unmix`, eigene Ordner."""
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
@ -7,7 +7,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SCRIPT = Path(__file__).with_name("songsplit.sh")
|
||||
SCRIPT = Path(__file__).with_name("unmix.sh")
|
||||
|
||||
|
||||
def make_exec(path: Path, body: str) -> Path:
|
||||
@ -19,10 +19,10 @@ def make_exec(path: Path, body: str) -> Path:
|
||||
|
||||
class WrapperTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(prefix="songsplit-wrapper-"))
|
||||
self.tmp = Path(tempfile.mkdtemp(prefix="unmix-wrapper-"))
|
||||
self.src = self.tmp / "src"
|
||||
self.src.mkdir()
|
||||
(self.src / "pyproject.toml").write_text("[project]\nname='songsplit'\n", encoding="utf-8")
|
||||
(self.src / "pyproject.toml").write_text("[project]\nname='unmix'\n", encoding="utf-8")
|
||||
self.venv = self.tmp / "venv"
|
||||
self.bin = self.tmp / "bin"
|
||||
self.bin.mkdir()
|
||||
@ -34,14 +34,14 @@ class WrapperTest(unittest.TestCase):
|
||||
shutil.rmtree(self.tmp, ignore_errors=True)
|
||||
|
||||
def run_script(self, *args, stdin="", env_extra=None):
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "SONGSPLIT_SRC": str(self.src), "SONGSPLIT_VENV": str(self.venv)}
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "UNMIX_SRC": str(self.src), "UNMIX_VENV": str(self.venv)}
|
||||
env.update(env_extra or {})
|
||||
return subprocess.run(["/bin/sh", str(SCRIPT), *args], input=stdin, text=True, capture_output=True, env=env)
|
||||
|
||||
def test_missing_source_points_to_the_submodule(self):
|
||||
empty = self.tmp / "leer"
|
||||
empty.mkdir()
|
||||
r = self.run_script("doctor", env_extra={"SONGSPLIT_SRC": str(empty)})
|
||||
r = self.run_script("doctor", env_extra={"UNMIX_SRC": str(empty)})
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn("git submodule update --init", r.stderr)
|
||||
|
||||
@ -52,25 +52,25 @@ class WrapperTest(unittest.TestCase):
|
||||
self.assertIn("setup", r.stderr)
|
||||
|
||||
def test_default_environment_is_under_xdg_data_home(self):
|
||||
# Ohne SONGSPLIT_VENV (Variable nicht gesetzt) gilt der Standardort unter XDG_DATA_HOME.
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "SONGSPLIT_SRC": str(self.src), "XDG_DATA_HOME": str(self.tmp / "xdg")}
|
||||
# Ohne UNMIX_VENV (Variable nicht gesetzt) gilt der Standardort unter XDG_DATA_HOME.
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "UNMIX_SRC": str(self.src), "XDG_DATA_HOME": str(self.tmp / "xdg")}
|
||||
r = subprocess.run(["/bin/sh", str(SCRIPT), "doctor"], text=True, capture_output=True, env=env)
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn(str(self.tmp / "xdg" / "singtrainer" / "songsplit-venv"), r.stderr)
|
||||
self.assertIn(str(self.tmp / "xdg" / "singtrainer" / "unmix-venv"), r.stderr)
|
||||
|
||||
def test_default_environment_falls_back_to_home_without_xdg(self):
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "SONGSPLIT_SRC": str(self.src)}
|
||||
env = {"PATH": str(self.bin), "HOME": str(self.tmp), "UNMIX_SRC": str(self.src)}
|
||||
r = subprocess.run(["/bin/sh", str(SCRIPT), "doctor"], text=True, capture_output=True, env=env)
|
||||
self.assertIn(str(self.tmp / ".local" / "share" / "singtrainer" / "songsplit-venv"), r.stderr)
|
||||
self.assertIn(str(self.tmp / ".local" / "share" / "singtrainer" / "unmix-venv"), r.stderr)
|
||||
|
||||
def test_arguments_are_passed_on_to_songsplit(self):
|
||||
make_exec(self.venv / "bin" / "songsplit", 'echo "ARGS: $*"\n')
|
||||
def test_arguments_are_passed_on_to_unmix(self):
|
||||
make_exec(self.venv / "bin" / "unmix", 'echo "ARGS: $*"\n')
|
||||
r = self.run_script("analyze", "lied.mp3", "-o", "ordner", "--lang", "de")
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertEqual(r.stdout.strip(), "ARGS: analyze lied.mp3 -o ordner --lang de")
|
||||
|
||||
def test_exit_code_of_songsplit_is_kept(self):
|
||||
make_exec(self.venv / "bin" / "songsplit", "exit 7\n")
|
||||
def test_exit_code_of_unmix_is_kept(self):
|
||||
make_exec(self.venv / "bin" / "unmix", "exit 7\n")
|
||||
self.assertEqual(self.run_script("doctor").returncode, 7)
|
||||
|
||||
def test_setup_without_uv_fails_clearly(self):
|
||||
1
tools/unmix
Submodule
1
tools/unmix
Submodule
Submodule tools/unmix added at 58ff3fe59a
57
tools/unmix.sh
Executable file
57
tools/unmix.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# Startet das Analysewerkzeug `unmix` (Songs in Songpacks zerlegen). Das Werkzeug liegt als Git-Submodul unter
|
||||
# tools/unmix, im Paket unter /usr/share/singtrainer/unmix; dieses Skript gibt es als tools/unmix.sh und im
|
||||
# Paket als /usr/bin/singtrainer-unmix.
|
||||
#
|
||||
# unmix.sh setup [--yes] einmalig: Python-Umgebung und Abhängigkeiten anlegen (lädt mehrere GB, fragt vorher)
|
||||
# unmix.sh doctor System- und Hardwareprüfung von unmix
|
||||
# unmix.sh analyze <audio> -o <ordner> [--lang de] alles andere geht an `unmix` weiter
|
||||
#
|
||||
# Die Umgebung liegt in $UNMIX_VENV (Standard: ~/.local/share/singtrainer/unmix-venv), der Quellordner in
|
||||
# $UNMIX_SRC (Standard: das Submodul neben diesem Skript oder das Paket). Die Einrichtung (`setup`) ist nicht getestet,
|
||||
# weil sie große Downloads macht; alles andere ist in tools/test_unmix_wrapper.py geprüft.
|
||||
set -eu
|
||||
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
src="${UNMIX_SRC:-}"
|
||||
if [ -z "$src" ]; then
|
||||
for c in "$here/unmix" /usr/share/singtrainer/unmix; do
|
||||
if [ -f "$c/pyproject.toml" ]; then src="$c"; break; fi
|
||||
done
|
||||
fi
|
||||
if [ -z "$src" ] || [ ! -f "$src/pyproject.toml" ]; then
|
||||
echo "unmix nicht gefunden. Im Repository: git submodule update --init tools/unmix" >&2
|
||||
echo "(oder UNMIX_SRC auf den Ordner setzen, der pyproject.toml enthält)." >&2
|
||||
exit 1
|
||||
fi
|
||||
venv="${UNMIX_VENV:-${XDG_DATA_HOME:-$HOME/.local/share}/singtrainer/unmix-venv}"
|
||||
|
||||
cmd="${1:-}"
|
||||
if [ "$cmd" = "setup" ]; then
|
||||
shift
|
||||
yes=0
|
||||
[ "${1:-}" = "--yes" ] && yes=1
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "uv fehlt (Python-Paketverwaltung). Arch: sudo pacman -S uv" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "unmix einrichten:"
|
||||
echo " Quelle: $src"
|
||||
echo " Umgebung: $venv"
|
||||
echo "Das lädt Python 3.12 (falls nicht vorhanden), torch, demucs, whisper und weitere Pakete aus dem Netz"
|
||||
echo "(mehrere GB); die Modelle folgen beim ersten Analyse-Lauf."
|
||||
if [ "$yes" -ne 1 ]; then
|
||||
printf "Fortfahren? [j/N] "
|
||||
read -r answer || answer=""
|
||||
case "$answer" in j|J|y|Y) ;; *) echo "Abgebrochen."; exit 1 ;; esac
|
||||
fi
|
||||
mkdir -p "$(dirname "$venv")"
|
||||
UV_PROJECT_ENVIRONMENT="$venv" exec uv sync --project "$src" --frozen --no-dev --no-editable --python 3.12
|
||||
fi
|
||||
|
||||
if [ ! -x "$venv/bin/unmix" ]; then
|
||||
echo "unmix ist noch nicht eingerichtet (kein $venv/bin/unmix)." >&2
|
||||
echo "Einmalig ausführen: $0 setup" >&2
|
||||
exit 1
|
||||
fi
|
||||
exec "$venv/bin/unmix" "$@"
|
||||
@ -2,7 +2,7 @@
|
||||
# Legt einen eigenen Arbeitsordner (git worktree) für eine Aufgabe an.
|
||||
# tools/worktree-new.sh <name> [basis-branch] (Standard-Basis: main)
|
||||
# Ergebnis: ../singstar-wt/<name> auf dem neuen Branch feat/<name>, mit Verknüpfungen auf die lokalen, nicht versionierten
|
||||
# Daten des Hauptordners; Git-Submodule (tools/songsplit) werden mit ausgecheckt. Regeln: siehe AGENTS.md.
|
||||
# Daten des Hauptordners; Git-Submodule (tools/unmix) werden mit ausgecheckt. Regeln: siehe AGENTS.md.
|
||||
set -eu
|
||||
name="${1:-}"
|
||||
base="${2:-main}"
|
||||
@ -15,7 +15,7 @@ dest="$(dirname "$main_dir")/singstar-wt/$name"
|
||||
branch="feat/$name"
|
||||
[ -e "$dest" ] && { echo "Existiert schon: $dest" >&2; exit 1; }
|
||||
git worktree add -b "$branch" "$dest" "$base"
|
||||
# Git-Submodule (songsplit) im neuen Arbeitsordner auschecken; ohne Netz bleibt es bei einem Hinweis.
|
||||
# Git-Submodule (unmix) im neuen Arbeitsordner auschecken; ohne Netz bleibt es bei einem Hinweis.
|
||||
git -C "$dest" submodule update --init --recursive \
|
||||
|| echo "Hinweis: Submodule nicht geholt; später: git -C $dest submodule update --init" >&2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user