This commit is contained in:
Shunsuke Shibayama 2022-08-14 01:42:57 +09:00
commit a7673ca8fb

View file

@ -6,17 +6,15 @@ use std::process::Command;
use crate::serialize::get_magic_num_from_bytes;
pub fn which_python() -> String {
let (cmd, python) = if cfg!(windows) {
("where", "python")
} else {
("which", "python3")
};
let (cmd, python) = if cfg!(windows) { ("where", "python") } else { ("which", "python3") };
let out = Command::new(cmd)
.arg(python)
.output()
.expect("python not found");
let res = String::from_utf8(out.stdout).unwrap();
let res = res.split('\n').next().unwrap_or("");
.arg(python)
.output()
.expect("python not found");
let res = String::from_utf8(out.stdout)
.unwrap()
.replace('\n', "")
.replace('\r', "");
if res.is_empty() {
panic!("python not found");
}