From 5d19b9124a248c23811da03da9896a07e6de12df Mon Sep 17 00:00:00 2001 From: namuyan Date: Sat, 12 Oct 2019 11:23:27 +0900 Subject: [PATCH] check python interpreter by --version --- build.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 7ee4b987..48526d40 100644 --- a/build.rs +++ b/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") };