mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Launcher: Run uv python install
before running uv sync
(#4162)
* Launcher: Run `uv python install` before running `uv sync` * Less copy/paste. * Minor readability improvements * Make sure we check file presence before attempting to read --------- Co-authored-by: Damien Elmes <gpg@ankiweb.net>
This commit is contained in:
parent
d1793550b0
commit
fc6447a938
4 changed files with 36 additions and 10 deletions
|
@ -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:
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8e3a5b5c841c512e5139daea0a9f0e2abdc47b8e
|
||||
Subproject commit 4a65d6012ac022a35f5c80c80b2b665447b6a525
|
|
@ -1 +1 @@
|
|||
Subproject commit 324e39e5bc7fa8311242c48104a1552d57d6ecfd
|
||||
Subproject commit f42461a6438cbe844150f543128d79a669bc4ef2
|
|
@ -284,6 +284,37 @@ fn main_menu_loop(state: &State) -> Result<()> {
|
|||
// Remove sync marker before attempting sync
|
||||
let _ = remove_file(&state.sync_complete_marker);
|
||||
|
||||
println!("\x1B[1mUpdating Anki...\x1B[0m\n");
|
||||
|
||||
let python_version_trimmed = 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")?;
|
||||
Some(python_version_str.trim().to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// `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 let Some(version) = &python_version_trimmed {
|
||||
command.args([version]);
|
||||
}
|
||||
|
||||
if let Err(e) = command.ensure_success() {
|
||||
println!("Python install failed: {e:#}");
|
||||
println!();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Sync the venv
|
||||
let mut command = Command::new(&state.uv_path);
|
||||
command
|
||||
|
@ -293,12 +324,8 @@ fn main_menu_loop(state: &State) -> Result<()> {
|
|||
.args(["sync", "--upgrade", "--managed-python"]);
|
||||
|
||||
// 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", python_version_trimmed]);
|
||||
if let Some(version) = &python_version_trimmed {
|
||||
command.args(["--python", version]);
|
||||
}
|
||||
|
||||
// Set UV_PRERELEASE=allow if beta mode is enabled
|
||||
|
@ -310,8 +337,6 @@ fn main_menu_loop(state: &State) -> Result<()> {
|
|||
command.env("UV_NO_CACHE", "1");
|
||||
}
|
||||
|
||||
println!("\x1B[1mUpdating Anki...\x1B[0m\n");
|
||||
|
||||
match command.ensure_success() {
|
||||
Ok(_) => {
|
||||
// Sync succeeded
|
||||
|
|
Loading…
Reference in a new issue