skia-bindings: revert changes made to the python location function
use crate::build_support::{android, binaries, cargo, clang, ios, llvm, vs, xcode};
use bindgen::{CodegenConfig, EnumVariation};
use cc::Build;
+use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
-use std::{
- path::{Path, PathBuf},
-};
use std::{env, fs};
/// The libraries to link with.
@@ -1299,7 +1297,6 @@ pub(crate) mod rewrite {
mod prerequisites {
use crate::build_support::{cargo, utils};
use flate2::read::GzDecoder;
- use std::env;
use std::ffi::OsStr;
use std::fs;
use std::io::Cursor;
@@ -1309,21 +1306,21 @@ mod prerequisites {
/// Resolves the full path
pub fn locate_python2_cmd() -> PathBuf {
- const PYTHON_CMDS: [&str; 4] = ["python", "python2", "python.exe", "python2.exe"];
- env::split_paths(&cargo::env_var("PATH").unwrap_or_default())
- .fold(None, |path_directory, buf|
- path_directory.or_else(||
- PYTHON_CMDS.iter()
- .fold(None, |path, executable_name|
- path.or_else(||
- is_python_version_2(buf.join(executable_name))))))
- .expect(&format!("Probing for Python 2 failed, please make sure that it's available in PATH, probed executables are: {:?}", PYTHON_CMDS))
+ const PYTHON_CMDS: [&str; 2] = ["python", "python2"];
+ for python in PYTHON_CMDS.as_ref() {
+ println!("Probing '{}'", python);
+ if let Some(true) = is_python_version_2(python) {
+ return python.into();
+ }
+ }
+
+ panic!(">>>>> Probing for Python 2 failed, please make sure that it's available in PATH, probed executables are: {:?} <<<<<", PYTHON_CMDS);
}
/// Returns true if the given python executable is python version 2.
/// or None if the executable was not found.
- pub fn is_python_version_2(exe: PathBuf) -> Option<PathBuf> {
- Command::new(&exe)
+ pub fn is_python_version_2(exe: impl AsRef<str>) -> Option<bool> {
+ Command::new(exe.as_ref())
.arg("--version")
.output()
.map(|output| {
@@ -1337,7 +1334,6 @@ mod prerequisites {
str.starts_with("Python 2.")
})
.ok()
- .and(Some(exe))
}
/// Resolve the skia and depot_tools subdirectory contents, either by checking out the
