install.sh: running it again (an update) keeps the engine's venv instead of failing in uv venv

This commit is contained in:
alex committed 2026-11-24 17:23:27 +00:00
1 parent 1214c9c182
commit ba7f0b9c73
2 files changed
+23 -1

No files matched your search

+17
View File
@@ -76,3 +76,20 @@ fn installs_the_binaries_from_where_cargo_puts_them() {
let out = String::from_utf8_lossy(&out.stdout);
assert!(out.contains("install -Dm755 /somewhere/else/target/release/summit "), "{out}");
}
#[test]
fn running_the_installer_again_keeps_the_venv() {
// `uv venv` fails on an existing venv ("A virtual environment already exists"): the second run, to update, died there.
let dir = std::env::temp_dir().join(format!("summit-install-test-again-{}", std::process::id()));
let prefix = dir.join("p");
let py = prefix.join("share/summit/engine/.venv/bin/python");
std::fs::create_dir_all(py.parent().unwrap()).unwrap();
std::fs::write(&py, "#!/bin/sh\n").unwrap();
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(&py, std::fs::Permissions::from_mode(0o755)).unwrap();
let out = dry_run(&prefix, &["--no-deps"]);
let _ = std::fs::remove_dir_all(&dir);
assert!(!out.contains("uv venv"), "{out}");
assert!(out.contains("the venv exists"), "{out}");
assert!(out.contains("uv pip install"), "{out}");
}
+6 -1
View File
@@ -394,7 +394,12 @@ setup_engine_venv() {
log " engine sources not found, skipping venv setup"
return
fi
run uv venv --python 3.12 "$engine_dir/.venv"
if [ -x "$engine_dir/.venv/bin/python" ]; then
# Running the installer again to update: `uv venv` refuses to replace a venv, and torch is already in it.
log " the venv exists: $engine_dir/.venv (kept; the packages below are brought up to date)"
else
run uv venv --python 3.12 "$engine_dir/.venv"
fi
if [ "$GPU_VENDOR" = "nvidia" ]; then
# torch first: requirements.txt only says torch>=2.6, and PyPI's default wheel is built for a newer CUDA than
# many installed drivers support (seen: torch 2.15+cu132 on a driver that stops at CUDA 13.0).