check python interpreter by --version
This commit is contained in:
parent
89b7c7e309
commit
5d19b9124a
9
build.rs
9
build.rs
|
@ -25,10 +25,13 @@ const MIN_VERSION: &'static str = "1.37.0-nightly";
|
|||
|
||||
lazy_static! {
|
||||
static ref PYTHON_INTERPRETER: &'static str = {
|
||||
["python3", "python"]
|
||||
["python", "python3"]
|
||||
.iter()
|
||||
.map(|bin| (bin, Command::new(bin).spawn()))
|
||||
.find(|(_, r)| r.is_ok())
|
||||
.map(|bin| (bin, Command::new(bin).arg("--version").output()))
|
||||
.filter(|(_, r)| r.is_ok())
|
||||
.map(|(bin, r)| (bin, r.unwrap().stderr))
|
||||
// begin with `Python 3.X.X :: additional info`
|
||||
.find(|(_, r)| r.starts_with(b"Python 3"))
|
||||
.map(|(bin, _)| bin)
|
||||
.expect("Python 3.x interpreter not found")
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue