Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minimum Rust version to 1.42.0-nightly #761

Merged
merged 4 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use version_check::{Channel, Date, Version};
/// Specifies the minimum nightly version needed to compile pyo3.
/// Keep this synced up with the travis ci config,
/// 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_VERSION: &'static str = "1.37.0-nightly";
const MIN_DATE: &str = "2019-07-18";
const MIN_VERSION: &str = "1.37.0-nightly";
//const PYTHON_INTERPRETER: &'static str = "python3";

lazy_static! {
Expand Down Expand Up @@ -85,7 +85,7 @@ impl fmt::Display for PythonVersion {

const PY3_MIN_MINOR: u8 = 5;

const CFG_KEY: &'static str = "py_sys_config";
const CFG_KEY: &str = "py_sys_config";

/// A list of python interpreter compile-time preprocessor defines that
/// we will pick up and pass to rustc via --cfg=py_sys_config={varname};
Expand All @@ -100,7 +100,7 @@ const CFG_KEY: &'static str = "py_sys_config";
/// (hrm, this is sort of re-implementing what distutils does, except
/// by passing command line args instead of referring to a python.h)
#[cfg(not(target_os = "windows"))]
static SYSCONFIG_FLAGS: [&'static str; 7] = [
static SYSCONFIG_FLAGS: [&str; 7] = [
"Py_USING_UNICODE",
"Py_UNICODE_WIDE",
"WITH_THREAD",
Expand All @@ -110,7 +110,7 @@ static SYSCONFIG_FLAGS: [&'static str; 7] = [
"COUNT_ALLOCS",
];

static SYSCONFIG_VALUES: [&'static str; 1] = [
static SYSCONFIG_VALUES: [&str; 1] = [
// cfg doesn't support flags with values, just bools - so flags
// below are translated into bools as {varname}_{val}
//
Expand Down Expand Up @@ -188,7 +188,7 @@ fn load_cross_compile_info() -> Result<(InterpreterConfig, HashMap<String, Strin
let shared = match config_map
.get("Py_ENABLE_SHARED")
.map(|x| x.as_str())
.ok_or("Py_ENABLE_SHARED is not defined".to_string())?
.ok_or_else(|| "Py_ENABLE_SHARED is not defined".to_string())?
{
"1" | "true" | "True" => true,
"0" | "false" | "False" => false,
Expand Down Expand Up @@ -279,7 +279,7 @@ fn get_config_vars(_: &str) -> Result<HashMap<String, String>, String> {
}

fn is_value(key: &str) -> bool {
SYSCONFIG_VALUES.iter().find(|x| **x == key).is_some()
SYSCONFIG_VALUES.iter().any(|x| *x == key)
}

fn cfg_line_for_var(key: &str, val: &str) -> Option<String> {
Expand Down Expand Up @@ -321,7 +321,7 @@ fn run_python_script(interpreter: &str, script: &str) -> Result<String, String>
};

if !out.status.success() {
return Err(format!("python script failed"));
return Err("python script failed".to_string());
}

Ok(String::from_utf8(out.stdout).unwrap())
Expand Down Expand Up @@ -451,7 +451,7 @@ fn find_interpreter_and_get_config() -> Result<(InterpreterConfig, HashMap<Strin
));
}

Err(format!("No python interpreter found"))
Err("No python interpreter found".to_string())
}

/// Extract compilation vars from the specified interpreter.
Expand Down Expand Up @@ -513,7 +513,7 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<String, String> {

if interpreter_config.version.implementation == PythonInterpreterKind::PyPy {
println!("cargo:rustc-cfg=PyPy");
flags += format!("CFG_PyPy").as_ref();
flags += "CFG_PyPy";
};

if interpreter_config.version.major == 2 {
Expand All @@ -533,7 +533,7 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<String, String> {
}
println!("cargo:rustc-cfg=Py_3");

return Ok(flags);
Ok(flags)
}

fn check_rustc_version() {
Expand Down Expand Up @@ -603,9 +603,8 @@ fn main() -> Result<(), String> {
}

for (key, val) in &config_map {
match cfg_line_for_var(key, val) {
Some(line) => println!("{}", line),
None => (),
if let Some(line) = cfg_line_for_var(key, val) {
println!("{}", line)
}
}

Expand Down Expand Up @@ -634,7 +633,7 @@ fn main() -> Result<(), String> {

println!(
"cargo:python_flags={}",
if flags.len() > 0 {
if !flags.is_empty() {
&flags[..flags.len() - 1]
} else {
""
Expand Down
1 change: 0 additions & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::ffi;
use crate::types::PyAny;
use crate::AsPyPointer;
use crate::Python;
use libc;
use std::ffi::CStr;
use std::os::raw;
use std::pin::Pin;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(specialization)]
#![allow(clippy::missing_safety_doc)] // FIXME (#698)

//! Rust bindings to the Python interpreter.
//!
Expand Down