mirror of
https://github.com/ankitects/anki.git
synced 2026-01-05 18:13:56 -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 {
|
||||
fn command(&self) -> &str {
|
||||
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 {
|
||||
"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)
|
||||
// override if PYTHON_BINARY is set
|
||||
let mut args = self.extra_args.to_string();
|
||||
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
|
||||
args = format!("--python {python_binary} {args}");
|
||||
} else {
|
||||
let python = env::var("PYTHON_BINARY").unwrap_or_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);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use crate::run::run_command;
|
|||
pub struct PyenvArgs {
|
||||
uv_bin: String,
|
||||
pyenv_folder: String,
|
||||
python: String,
|
||||
#[arg(trailing_var_arg = true)]
|
||||
extra_args: Vec<String>,
|
||||
}
|
||||
|
|
@ -45,6 +46,7 @@ pub fn setup_pyenv(args: PyenvArgs) {
|
|||
command
|
||||
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
|
||||
.args(["sync", "--locked", "--no-config"])
|
||||
.args(["--python", &args.python])
|
||||
.args(args.extra_args),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue