complicated method chain
This commit is contained in:
parent
4b1c48831a
commit
91b3231038
12
build.rs
12
build.rs
|
@ -27,12 +27,14 @@ lazy_static! {
|
||||||
static ref PYTHON_INTERPRETER: &'static str = {
|
static ref PYTHON_INTERPRETER: &'static str = {
|
||||||
["python", "python3"]
|
["python", "python3"]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bin| (bin, Command::new(bin).arg("--version").output()))
|
.find(|bin| {
|
||||||
.filter(|(_, r)| r.is_ok())
|
if let Ok(out) = Command::new(bin).arg("--version").output() {
|
||||||
.map(|(bin, r)| (bin, r.unwrap()))
|
|
||||||
// begin with `Python 3.X.X :: additional info`
|
// begin with `Python 3.X.X :: additional info`
|
||||||
.find(|(_, r)| r.stdout.starts_with(b"Python 3") || r.stderr.starts_with(b"Python 3"))
|
out.stdout.starts_with(b"Python 3") || out.stderr.starts_with(b"Python 3")
|
||||||
.map(|(bin, _)| bin)
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
.expect("Python 3.x interpreter not found")
|
.expect("Python 3.x interpreter not found")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue