Search for both python3 and python
This commit is contained in:
parent
bd426d4065
commit
fe9575a34d
|
@ -38,6 +38,7 @@ regex = "1.2.1"
|
||||||
version_check = "0.9.1"
|
version_check = "0.9.1"
|
||||||
serde = { version = "1.0.99", features = ["derive"] }
|
serde = { version = "1.0.99", features = ["derive"] }
|
||||||
serde_json = "1.0.40"
|
serde_json = "1.0.40"
|
||||||
|
lazy_static = "1.4"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
26
build.rs
26
build.rs
|
@ -1,3 +1,6 @@
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -18,7 +21,18 @@ use version_check::{Channel, Date, Version};
|
||||||
/// But note that this is the rustc version which can be lower than the nightly version
|
/// But note that this is the rustc version which can be lower than the nightly version
|
||||||
const MIN_DATE: &'static str = "2019-07-18";
|
const MIN_DATE: &'static str = "2019-07-18";
|
||||||
const MIN_VERSION: &'static str = "1.37.0-nightly";
|
const MIN_VERSION: &'static str = "1.37.0-nightly";
|
||||||
const PYTHON_INTERPRETER: &'static str = "python3";
|
//const PYTHON_INTERPRETER: &'static str = "python3";
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref PYTHON_INTERPRETER: &'static str = {
|
||||||
|
["python3", "python"]
|
||||||
|
.iter()
|
||||||
|
.map(|bin| (bin, Command::new(bin).spawn()))
|
||||||
|
.find(|(_, r)| r.is_ok())
|
||||||
|
.map(|(bin, _)| bin)
|
||||||
|
.expect("Python 3.x interpreter not found")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Information returned from python interpreter
|
/// Information returned from python interpreter
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
@ -358,7 +372,7 @@ elif sysconfig.get_config_var("Py_ENABLE_SHARED"):
|
||||||
else:
|
else:
|
||||||
print("static")
|
print("static")
|
||||||
"#;
|
"#;
|
||||||
let out = run_python_script(PYTHON_INTERPRETER, script).unwrap();
|
let out = run_python_script(&PYTHON_INTERPRETER, script).unwrap();
|
||||||
Ok(out.trim_end().to_owned())
|
Ok(out.trim_end().to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,19 +440,19 @@ fn find_interpreter_and_get_config() -> Result<(InterpreterConfig, HashMap<Strin
|
||||||
};
|
};
|
||||||
|
|
||||||
// check default python
|
// check default python
|
||||||
let interpreter_config = get_config_from_interpreter(PYTHON_INTERPRETER)?;
|
let interpreter_config = get_config_from_interpreter(&PYTHON_INTERPRETER)?;
|
||||||
if interpreter_config.version.major == 3 {
|
if interpreter_config.version.major == 3 {
|
||||||
return Ok((
|
return Ok((
|
||||||
interpreter_config,
|
interpreter_config,
|
||||||
fix_config_map(get_config_vars(PYTHON_INTERPRETER)?),
|
fix_config_map(get_config_vars(&PYTHON_INTERPRETER)?),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let interpreter_config = get_config_from_interpreter(PYTHON_INTERPRETER)?;
|
let interpreter_config = get_config_from_interpreter(&PYTHON_INTERPRETER)?;
|
||||||
if interpreter_config.version.major == 3 {
|
if interpreter_config.version.major == 3 {
|
||||||
return Ok((
|
return Ok((
|
||||||
interpreter_config,
|
interpreter_config,
|
||||||
fix_config_map(get_config_vars(PYTHON_INTERPRETER)?),
|
fix_config_map(get_config_vars(&PYTHON_INTERPRETER)?),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue