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