use std::path::PathBuf;
use rattler_conda_types::Platform;
use crate::execution::{ExecutionArgs, ResolvedScriptContents};
use super::{BashInterpreter, CmdExeInterpreter, Interpreter, InterpreterError, find_interpreter};
pub struct PythonInterpreter;
impl Interpreter for PythonInterpreter {
async fn run(&self, args: ExecutionArgs) -> Result<(), InterpreterError> {
let py_script = args.work_dir.join("conda_build_script.py");
tokio::fs::write(&py_script, args.script.script()).await?;
let args = ExecutionArgs {
script: ResolvedScriptContents::Inline(format!("python {:?}", py_script)),
..args
};
if cfg!(windows) {
CmdExeInterpreter.run(args).await
} else {
BashInterpreter.run(args).await
}
}
async fn find_interpreter(
&self,
build_prefix: Option<&PathBuf>,
platform: &Platform,
) -> Result<Option<PathBuf>, which::Error> {
find_interpreter("python", build_prefix, platform)
}
}