Launcher: Run uv python install before running uv sync

This commit is contained in:
Kevin Nakamura 2025-07-05 00:22:42 +09:00
parent d1793550b0
commit 547d022f09
No known key found for this signature in database
GPG key ID: 8CBF0A1C58E5523E
2 changed files with 27 additions and 0 deletions

View file

@ -233,6 +233,7 @@ Spiritual Father <https://github.com/spiritualfather>
Emmanuel Ferdman <https://github.com/emmanuel-ferdman>
Sunong2008 <https://github.com/Sunrongguo2008>
Marvin Kopf <marvinkopf@outlook.com>
Kevin Nakamura <grinkers@grinkers.net>
********************
The text of the 3 clause BSD license follows:

View file

@ -284,6 +284,32 @@ fn main_menu_loop(state: &State) -> Result<()> {
// Remove sync marker before attempting sync
let _ = remove_file(&state.sync_complete_marker);
println!("\x1B[1mInstalling Managed Python...\x1B[0m\n");
// `uv sync` does not pull in Python automatically, unlike `uv run`.
// This might be system/platform specific and/or a uv bug.
let mut command = Command::new(&state.uv_path);
command
.current_dir(&state.uv_install_root)
.env("UV_CACHE_DIR", &state.uv_cache_dir)
.env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir)
.args(["python", "install"]);
// Add python version if .python-version file exists
if state.user_python_version_path.exists() {
let python_version = read_file(&state.user_python_version_path)?;
let python_version_str = String::from_utf8(python_version)
.context("Invalid UTF-8 in .python-version")?;
let python_version_trimmed = python_version_str.trim();
command.args([python_version_trimmed]);
}
if let Err(e) = command.ensure_success() {
println!("Managed Python Install failed: {e:#}");
println!();
continue;
}
// Sync the venv
let mut command = Command::new(&state.uv_path);
command