mirror of
https://github.com/ankitects/anki.git
synced 2026-01-07 02:53:54 -05:00
Merge 5d2db20897 into 8f2144534b
This commit is contained in:
commit
61dee280c2
2 changed files with 15 additions and 7 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;
|
||||||
|
|
@ -123,7 +124,7 @@ pub struct PythonEnvironment {
|
||||||
impl BuildAction for PythonEnvironment {
|
impl BuildAction for PythonEnvironment {
|
||||||
fn command(&self) -> &str {
|
fn command(&self) -> &str {
|
||||||
if env::var("OFFLINE_BUILD").is_err() {
|
if env::var("OFFLINE_BUILD").is_err() {
|
||||||
"$runner pyenv $uv_binary $builddir/$pyenv_folder -- $extra_args"
|
"$runner pyenv $uv_binary $builddir/$pyenv_folder $python -- $extra_args"
|
||||||
} else {
|
} else {
|
||||||
"echo 'OFFLINE_BUILD is set. Using the existing PythonEnvironment.'"
|
"echo 'OFFLINE_BUILD is set. Using the existing PythonEnvironment.'"
|
||||||
}
|
}
|
||||||
|
|
@ -145,12 +146,17 @@ 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)
|
||||||
let mut args = self.extra_args.to_string();
|
// override if PYTHON_BINARY is set
|
||||||
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
|
let python = env::var("PYTHON_BINARY").unwrap_or_else(|_| {
|
||||||
args = format!("--python {python_binary} {args}");
|
let python_version =
|
||||||
}
|
read_file(".python-version").expect("No .python-version in cwd");
|
||||||
build.add_variable("extra_args", args);
|
let python_version_str =
|
||||||
|
String::from_utf8(python_version).expect("Invalid UTF-8 in .python-version");
|
||||||
|
python_version_str.trim().to_string()
|
||||||
|
});
|
||||||
|
build.add_variable("python", python);
|
||||||
|
build.add_variable("extra_args", self.extra_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
build.add_outputs_ext("bin", bin_path("python"), true);
|
build.add_outputs_ext("bin", bin_path("python"), true);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use crate::run::run_command;
|
||||||
pub struct PyenvArgs {
|
pub struct PyenvArgs {
|
||||||
uv_bin: String,
|
uv_bin: String,
|
||||||
pyenv_folder: String,
|
pyenv_folder: String,
|
||||||
|
python: String,
|
||||||
#[arg(trailing_var_arg = true)]
|
#[arg(trailing_var_arg = true)]
|
||||||
extra_args: Vec<String>,
|
extra_args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -45,6 +46,7 @@ pub fn setup_pyenv(args: PyenvArgs) {
|
||||||
command
|
command
|
||||||
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
|
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
|
||||||
.args(["sync", "--locked", "--no-config"])
|
.args(["sync", "--locked", "--no-config"])
|
||||||
|
.args(["--python", &args.python])
|
||||||
.args(args.extra_args),
|
.args(args.extra_args),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue