Skip to content

Fast local LLM inference on plain CPUs. No GPU, 8 GB of RAM. OpenAI-compatible server.

fix(install): require git before fetching the MTP reader (#58)

Afloatbc4522b36006
diff --git a/install.sh b/install.sh
index c0741f0..dceb273 100755
--- a/install.sh
+++ b/install.sh
@@ -90,8 +90,10 @@ need_tools=()
command -v curl >/dev/null || need_tools+=(curl)
command -v python3 >/dev/null || need_tools+=(python3)
BUILD=1; { [ -n "$BIN_URL" ] || [ "$MODEL_ONLY" = 1 ]; } && BUILD=0
+NEED_GIT=$BUILD
+if [ "$MTP" = 1 ] && [ ! -f "$PREFIX/models/model.gguf" ] && [ ! -d "$PREFIX/llama.cpp/gguf-py" ]; then NEED_GIT=1; fi
+if [ "$NEED_GIT" = 1 ]; then command -v git >/dev/null || need_tools+=(git); fi
if [ "$BUILD" = 1 ]; then
- command -v git >/dev/null || need_tools+=(git)
command -v cmake >/dev/null || need_tools+=(cmake)
command -v c++ >/dev/null || need_tools+=(build-essential)
command -v ninja >/dev/null || need_tools+=(ninja-build)
@@ -114,7 +116,8 @@ if [ "$BUILD" = 1 ] && ! command -v cmake >/dev/null; then # no apt/sudo: cmak
"$PREFIX/venv/bin/pip" install -q cmake ninja && export PATH="$PREFIX/venv/bin:$PATH"
fi
for t in curl python3; do command -v $t >/dev/null || die "missing $t"; done
-if [ "$BUILD" = 1 ]; then for t in git cmake c++; do command -v $t >/dev/null || die "missing $t. On Ubuntu or Debian: sudo apt install -y build-essential cmake git (or use --bin-url)"; done; fi
+if [ "$NEED_GIT" = 1 ]; then command -v git >/dev/null || die "missing git; install git to build the engine or fetch the MTP reader"; fi
+if [ "$BUILD" = 1 ]; then for t in cmake c++; do command -v $t >/dev/null || die "missing $t. On Ubuntu or Debian: sudo apt install -y build-essential cmake git (or use --bin-url)"; done; fi
# ---------------------------------------------------------------- engine
SRC=$PREFIX/llama.cpp
diff --git a/tests/test_install_mtp_git.py b/tests/test_install_mtp_git.py
new file mode 100644
index 0000000..f42809a
--- /dev/null
+++ b/tests/test_install_mtp_git.py
@@ -0,0 +1,58 @@
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import tempfile
+import unittest
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+class InstallRegression(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.work = Path(self.temp.name)
+ self.prefix = self.work / "installation"
+ self.tools = self.work / "tools"
+ self.tools.mkdir()
+ (self.prefix / "bin").mkdir(parents=True)
+ (self.prefix / "models").mkdir()
+ self.command(self.prefix / "bin/llama-server", "#!/bin/sh\nexit 0\n")
+ for name in ("dirname", "uname", "grep", "cut", "sed", "awk", "cat", "mkdir", "id",
+ "mv", "rm", "touch", "tar", "gzip", "head", "mktemp", "basename", "flock"):
+ executable = shutil.which(name)
+ if executable:
+ (self.tools / name).symlink_to(executable)
+ self.command(self.tools / "df", "#!/bin/sh\nprintf 'Filesystem 1024-blocks Used Available Capacity Mounted\nfixture 999999999 0 999999999 0%% /\n'\n")
+ self.command(self.tools / "du", "#!/bin/sh\nprintf '0 fixture\n'\n")
+ self.command(self.tools / "python3", "#!/bin/sh\nexit 0\n")
+ self.command(self.tools / "curl", "#!/bin/sh\nprintf download >> \"$DOWNLOAD_LOG\"\nwhile [ \"$#\" -gt 0 ]; do if [ \"$1\" = -o ]; then shift; printf fixture > \"$1\"; fi; shift; done\n")
+ self.env = {**os.environ, "OPENSET_LLM_HOME": str(self.prefix),
+ "PATH": str(self.tools), "DOWNLOAD_LOG": str(self.work / "downloads")}
+ self.env.pop("OPENSET_LLM_BIN_URL", None)
+ self.env.pop("HF_TOKEN", None)
+
+ def command(self, path, content):
+ path.write_text(content)
+ path.chmod(0o755)
+
+ def install(self, *args):
+ return subprocess.run(["/bin/bash", str(ROOT / "install.sh"), *args],
+ env=self.env, text=True, capture_output=True, timeout=15)
+
+ def test_mtp_fetch_checks_git_before_downloading_weights(self):
+ result = self.install("--model-only")
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("missing git", result.stderr)
+ self.assertFalse((self.work / "downloads").exists(), result.stdout)
+
+ def test_no_mtp_does_not_need_git(self):
+ (self.prefix / "models/base.gguf").write_bytes(b"base")
+ result = self.install("--model-only", "--no-mtp")
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual((self.prefix / "models/model.gguf").read_bytes(), b"base")
+
+
+if __name__ == "__main__":
+ unittest.main()