mirror of
https://github.com/ankitects/anki.git
synced 2026-01-10 04:23:54 -05:00
fix(build): respect .python-version when generating pyenv
This commit is contained in:
parent
9facea0a66
commit
55691fc254
1 changed files with 10 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
use anki_io::read_file;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use camino::Utf8Path;
|
use camino::Utf8Path;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
|
|
@ -145,10 +146,18 @@ impl BuildAction for PythonEnvironment {
|
||||||
if env::var("OFFLINE_BUILD").is_err() {
|
if env::var("OFFLINE_BUILD").is_err() {
|
||||||
build.add_inputs("uv_binary", inputs![":uv_binary"]);
|
build.add_inputs("uv_binary", inputs![":uv_binary"]);
|
||||||
|
|
||||||
// Add --python flag to extra_args if PYTHON_BINARY is set
|
// Set --python flag to .python-version (--no-config ignores it)
|
||||||
|
// override if PYTHON_BINARY is set
|
||||||
let mut args = self.extra_args.to_string();
|
let mut args = self.extra_args.to_string();
|
||||||
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
|
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
|
||||||
args = format!("--python {python_binary} {args}");
|
args = format!("--python {python_binary} {args}");
|
||||||
|
} else {
|
||||||
|
let python_version =
|
||||||
|
read_file(".python-version").expect("No .python-version in cwd");
|
||||||
|
let python_version_str =
|
||||||
|
String::from_utf8(python_version).expect("Invalid UTF-8 in .python-version");
|
||||||
|
let python_version_trimmed = python_version_str.trim().to_string();
|
||||||
|
args = format!("--python {python_version_trimmed} {args}");
|
||||||
}
|
}
|
||||||
build.add_variable("extra_args", args);
|
build.add_variable("extra_args", args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue