mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 21:01:10 +00:00
Fixed error when multiple Pythons are found
This commit is contained in:
parent
a7673ca8fb
commit
fe8c7ff95a
1 changed files with 10 additions and 8 deletions
|
@ -6,15 +6,17 @@ use std::process::Command;
|
||||||
use crate::serialize::get_magic_num_from_bytes;
|
use crate::serialize::get_magic_num_from_bytes;
|
||||||
|
|
||||||
pub fn which_python() -> String {
|
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)
|
let out = Command::new(cmd)
|
||||||
.arg(python)
|
.arg(python)
|
||||||
.output()
|
.output()
|
||||||
.expect("python not found");
|
.expect("python not found");
|
||||||
let res = String::from_utf8(out.stdout)
|
let res = String::from_utf8(out.stdout).unwrap();
|
||||||
.unwrap()
|
let res = res.split('\n').next().unwrap_or("").replace('\r', "");
|
||||||
.replace('\n', "")
|
|
||||||
.replace('\r', "");
|
|
||||||
if res.is_empty() {
|
if res.is_empty() {
|
||||||
panic!("python not found");
|
panic!("python not found");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue