pass Py_3_x cfg var with links
This commit is contained in:
parent
23c36f5714
commit
364d7af69c
6
build.rs
6
build.rs
|
@ -27,14 +27,18 @@ fn main() {
|
|||
for f in flags.split(",") {
|
||||
// write out flags as --cfg so that the same #cfg blocks can be used
|
||||
// in rust-cpython as in the -sys libs
|
||||
if f.starts_with("CFG") {
|
||||
println!("cargo:rustc-cfg={}", &f[4..])
|
||||
} else {
|
||||
let key_and_val: Vec<&str> = f.split("=").collect();
|
||||
let key = key_and_val[0];
|
||||
let val = key_and_val[1];
|
||||
if key.starts_with("FLAG") {
|
||||
println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, &key[5..])
|
||||
println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, &key[5..]);
|
||||
} else {
|
||||
println!("cargo:rustc-cfg={}=\"{}_{}\"", CFG_KEY, &key[4..], val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ print(sys.exec_prefix);";
|
|||
/// cargo vars to stdout.
|
||||
///
|
||||
/// Note that if the python doesn't satisfy expected_version, this will error.
|
||||
fn configure_from_path(expected_version: &PythonVersion) -> Result<String, String> {
|
||||
fn configure_from_path(expected_version: &PythonVersion) -> Result<(String, String), String> {
|
||||
let (interpreter_version, interpreter_path, lines) =
|
||||
try!(find_interpreter_and_get_config(expected_version));
|
||||
let libpath: &str = &lines[1];
|
||||
|
@ -325,6 +325,7 @@ fn configure_from_path(expected_version: &PythonVersion) -> Result<String, Strin
|
|||
}
|
||||
}
|
||||
|
||||
let mut flags = String::new();
|
||||
|
||||
if let PythonVersion { major: 3, minor: some_minor} = interpreter_version {
|
||||
if env::var_os("CARGO_FEATURE_PEP_384").is_some() {
|
||||
|
@ -333,11 +334,11 @@ fn configure_from_path(expected_version: &PythonVersion) -> Result<String, Strin
|
|||
if let Some(minor) = some_minor {
|
||||
for i in 4..(minor+1) {
|
||||
println!("cargo:rustc-cfg=Py_3_{}", i);
|
||||
flags += format!("CFG_Py_3_{},", i).as_ref();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(interpreter_path);
|
||||
return Ok((interpreter_path, flags));
|
||||
}
|
||||
|
||||
/// Determine the python version we're supposed to be building
|
||||
|
@ -380,7 +381,7 @@ fn main() {
|
|||
// try using 'env' (sorry but this isn't our fault - it just has to
|
||||
// match the pkg-config package name, which is going to have a . in it).
|
||||
let version = version_from_env().unwrap();
|
||||
let python_interpreter_path = configure_from_path(&version).unwrap();
|
||||
let (python_interpreter_path, flags) = configure_from_path(&version).unwrap();
|
||||
let config_map = get_config_vars(&python_interpreter_path).unwrap();
|
||||
for (key, val) in &config_map {
|
||||
match cfg_line_for_var(key, val) {
|
||||
|
@ -402,6 +403,7 @@ fn main() {
|
|||
// rust-cypthon/build.rs contains an example of how to unpack this data
|
||||
// into cfg flags that replicate the ones present in this library, so
|
||||
// you can use the same cfg syntax.
|
||||
//let mut flags = flags;
|
||||
let flags: String = config_map.iter().fold("".to_owned(), |memo, (key, val)| {
|
||||
if is_value(key) {
|
||||
memo + format!("VAL_{}={},", key, val).as_ref()
|
||||
|
@ -410,7 +412,8 @@ fn main() {
|
|||
} else {
|
||||
memo
|
||||
}
|
||||
});
|
||||
}) + flags.as_str();
|
||||
|
||||
println!("cargo:python_flags={}",
|
||||
if flags.len() > 0 { &flags[..flags.len()-1] } else { "" });
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ macro_rules! py_class_type_object_dynamic_init {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(Py_3_4))]
|
||||
#[cfg(not(Py_3_5))]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! py_class_type_object_dynamic_init {
|
||||
|
@ -221,6 +221,7 @@ macro_rules! py_class_as_number {
|
|||
macro_rules! py_class_as_async {
|
||||
([]) => (0 as *mut $crate::_detail::ffi::PyAsyncMethods);
|
||||
([$( $slot_name:ident : $slot_value:expr ,)+]) => {{
|
||||
println!("register async");
|
||||
static mut ASYNC_METHODS : $crate::_detail::ffi::PyAsyncMethods
|
||||
= $crate::_detail::ffi::PyAsyncMethods {
|
||||
$( $slot_name : $slot_value, )*
|
||||
|
|
Loading…
Reference in New Issue