Skip to content

Clone your own voice on your own computer: speak any text in 60+ languages and dub videos into another language in your voice. Fully local. Early version.

fix(setup): install the Character voices runtime on a fresh runtime (#185)

Taras Hevlich3605c583db15
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd6873d..c0288e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Unreleased
+* **Setup finishes again with Character voices:** a first install with them (on by default with a GPU of 10 GB or a
+ Mac) stopped at "Character voices: runtime" with a FileNotFoundError, and so did adding them in Settings > Modules.
* **Release pages start with a download table:** the Windows, Linux and macOS installers, each a direct link, above
the notes. The Updates window leaves the table out and shows a release's warning as plain text.
diff --git a/engine/tests/test_setup_tool.py b/engine/tests/test_setup_tool.py
index f84eba8..d6ac82d 100644
--- a/engine/tests/test_setup_tool.py
+++ b/engine/tests/test_setup_tool.py
@@ -1,8 +1,12 @@
import importlib.util
+import io
import json
import os
+import shutil
import sys
+import tarfile
import time
+import zipfile
from pathlib import Path
from types import SimpleNamespace
@@ -549,6 +553,32 @@ def test_character_voices_take_the_gemma_file_sing_left(tmp_path, monkeypatch):
assert not old.parent.exists()
+ ("plat", "name", "top"),
+ [("windows", "llama-win.zip", ""), ("linux", "llama-linux.tar.gz", "llama-b1/")],
+)
+def test_the_character_voices_runtime_installs_on_a_fresh_runtime(tmp_path, monkeypatch, plat, name, top):
+ exe = "llama-server.exe" if plat == "windows" else "llama-server"
+ built = tmp_path / name
+ if name.endswith(".zip"):
+ with zipfile.ZipFile(built, "w") as z:
+ z.writestr(f"{top}{exe}", b"server")
+ else:
+ with tarfile.open(built, "w:gz") as tar:
+ info = tarfile.TarInfo(f"{top}{exe}")
+ info.size = 6
+ tar.addfile(info, io.BytesIO(b"server"))
+ s = setup.Setup(root=tmp_path / "root", plat=plat, arch="x64", data_dir=tmp_path / "data", uv_path="uv")
+ monkeypatch.setattr(setup.Setup, "llama_build", lambda self: (name, "sha"))
+ monkeypatch.setattr(setup, "url_bytes", lambda url: 6)
+ monkeypatch.setattr(setup, "expect_download", lambda size: None)
+ monkeypatch.setattr(setup, "fetch_checked", lambda url, dest, sha, label: shutil.copy(built, dest))
+ s.cast_runtime()
+ assert (s.llama_dir / exe).read_bytes() == b"server"
+ assert s.has_llama()
+ assert not (s.temp_dir() / "llama-unpack").exists()
+
+
def test_llama_build_follows_the_gpu(tmp_path, nvidia):
s = make(tmp_path / "a")
s.detect()
diff --git a/tools/setup/setup.py b/tools/setup/setup.py
index b99ccca..03996ee 100644
--- a/tools/setup/setup.py
+++ b/tools/setup/setup.py
@@ -2914,6 +2914,9 @@ def ask_data_dir(plat: str, default: Path) -> Path:
def _rmtree(path: Path) -> None:
+ if not os.path.lexists(path):
+ return
+
def writable(func, target, _exc) -> None: # noqa: ANN001 - shutil's callback
# Windows refuses to delete read-only files (git objects, some wheels).
Path(target).chmod(0o700)