mirror of
https://github.com/ankitects/anki.git
synced 2026-01-08 03:23:54 -05:00
refactor
This commit is contained in:
parent
55691fc254
commit
5d2db20897
2 changed files with 8 additions and 9 deletions
|
|
@ -124,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.'"
|
||||||
}
|
}
|
||||||
|
|
@ -148,18 +148,15 @@ impl BuildAction for PythonEnvironment {
|
||||||
|
|
||||||
// Set --python flag to .python-version (--no-config ignores it)
|
// Set --python flag to .python-version (--no-config ignores it)
|
||||||
// override if PYTHON_BINARY is set
|
// override if PYTHON_BINARY is set
|
||||||
let mut args = self.extra_args.to_string();
|
let python = env::var("PYTHON_BINARY").unwrap_or_else(|_| {
|
||||||
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
|
|
||||||
args = format!("--python {python_binary} {args}");
|
|
||||||
} else {
|
|
||||||
let python_version =
|
let python_version =
|
||||||
read_file(".python-version").expect("No .python-version in cwd");
|
read_file(".python-version").expect("No .python-version in cwd");
|
||||||
let python_version_str =
|
let python_version_str =
|
||||||
String::from_utf8(python_version).expect("Invalid UTF-8 in .python-version");
|
String::from_utf8(python_version).expect("Invalid UTF-8 in .python-version");
|
||||||
let python_version_trimmed = python_version_str.trim().to_string();
|
python_version_str.trim().to_string()
|
||||||
args = format!("--python {python_version_trimmed} {args}");
|
});
|
||||||
}
|
build.add_variable("python", python);
|
||||||
build.add_variable("extra_args", args);
|
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