Merge pull request #620 from namuyan/master
check python interpreter by --version option
This commit is contained in:
commit
77f8cad65f
13
build.rs
13
build.rs
|
@ -25,11 +25,16 @@ const MIN_VERSION: &'static str = "1.37.0-nightly";
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref PYTHON_INTERPRETER: &'static str = {
|
static ref PYTHON_INTERPRETER: &'static str = {
|
||||||
["python3", "python"]
|
["python", "python3"]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bin| (bin, Command::new(bin).spawn()))
|
.find(|bin| {
|
||||||
.find(|(_, r)| r.is_ok())
|
if let Ok(out) = Command::new(bin).arg("--version").output() {
|
||||||
.map(|(bin, _)| bin)
|
// begin with `Python 3.X.X :: additional info`
|
||||||
|
out.stdout.starts_with(b"Python 3") || out.stderr.starts_with(b"Python 3")
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
.expect("Python 3.x interpreter not found")
|
.expect("Python 3.x interpreter not found")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue