diff --git a/Readme.md b/Readme.md index 02f51851b..7eb317004 100644 --- a/Readme.md +++ b/Readme.md @@ -136,7 +136,8 @@ OPTIONS: Whether to use and check for compliance with the manylinux1 tag (1), use it but don't check compliance (1- unchecked) or use the native linux tag (off) - This option is ignored on all non-linux platforms [default: 1] [possible values: 1, 1-unchecked, off] + This option is ignored on all non-linux platforms [default: 1] [possible values: 1, 1-unchecked, 2010, + 2010-unchecked, off] -o, --out The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory @@ -187,7 +188,8 @@ OPTIONS: Whether to use and check for compliance with the manylinux1 tag (1), use it but don't check compliance (1- unchecked) or use the native linux tag (off) - This option is ignored on all non-linux platforms [default: 1] [possible values: 1, 1-unchecked, off] + This option is ignored on all non-linux platforms [default: 1] [possible values: 1, 1-unchecked, 2010, + 2010-unchecked, off] -o, --out The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory diff --git a/src/auditwheel.rs b/src/auditwheel.rs index a009da4ff..6765c9c2e 100644 --- a/src/auditwheel.rs +++ b/src/auditwheel.rs @@ -1,3 +1,5 @@ +use crate::Manylinux; +use crate::Target; use failure::Fail; use goblin; use goblin::elf::Elf; @@ -36,7 +38,6 @@ const MANYLINUX1: &[&str] = &[ /// As specified in "PEP 571 -- The manylinux2010 Platform Tag" /// /// Currently unused since the python ecosystem is still on manylinux 1 -#[allow(unused)] const MANYLINUX2010: &[&str] = &[ "libgcc_s.so.1", "libstdc++.so.6", @@ -84,7 +85,20 @@ pub enum AuditWheelError { /// /// Only checks for the libraries marked as NEEDED, but not for symbol versions /// (e.g. requiring a too recent glibc isn't caught). -pub fn auditwheel_rs(path: &Path) -> Result<(), AuditWheelError> { +pub fn auditwheel_rs( + path: &Path, + target: &Target, + manylinux: &Manylinux, +) -> Result<(), AuditWheelError> { + if !target.is_linux() { + return Ok(()); + } + let reference: &[&str]; + match *manylinux { + Manylinux::Manylinux1 => reference = MANYLINUX1, + Manylinux::Manylinux2010 => reference = MANYLINUX2010, + _ => return Ok(()), + }; let mut file = File::open(path).map_err(AuditWheelError::IOError)?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer) @@ -100,7 +114,7 @@ pub fn auditwheel_rs(path: &Path) -> Result<(), AuditWheelError> { if dep == "ld-linux-x86-64.so.2" || dep == "ld-linux.so.2" { continue; } - if !MANYLINUX1.contains(&dep.as_str()) { + if !reference.contains(&dep.as_str()) { offenders.push(dep); } } diff --git a/src/build_context.rs b/src/build_context.rs index a8b507cf8..5fdd24089 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -1,5 +1,5 @@ #[cfg(feature = "auditwheel")] -use crate::auditwheel_rs; +use crate::auditwheel::auditwheel_rs; use crate::compile; use crate::module_writer::WheelWriter; use crate::module_writer::{write_bin, write_bindings_module, write_cffi_module}; @@ -154,10 +154,9 @@ impl BuildContext { .map(|x| &x.target) .unwrap_or(&self.target); - if self.manylinux == Manylinux::Manylinux1 && target.is_linux() { - #[cfg(feature = "auditwheel")] - auditwheel_rs(&artifact).context("Failed to ensure manylinux compliance")?; - } + #[cfg(feature = "auditwheel")] + auditwheel_rs(&artifact, target, &self.manylinux) + .context("Failed to ensure manylinux compliance")?; Ok(artifact) } @@ -207,10 +206,9 @@ impl BuildContext { .cloned() .ok_or_else(|| Context::new("Cargo didn't build a binary."))?; - if self.manylinux != Manylinux::Manylinux1Unchecked && self.target.is_linux() { - #[cfg(feature = "auditwheel")] - auditwheel_rs(&artifact).context("Failed to ensure manylinux compliance")?; - } + #[cfg(feature = "auditwheel")] + auditwheel_rs(&artifact, &self.target, &self.manylinux) + .context("Failed to ensure manylinux compliance")?; let (tag, tags) = self.get_unversal_tags(); diff --git a/src/build_options.rs b/src/build_options.rs index 94fde8020..89014f6ed 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -31,7 +31,7 @@ pub struct BuildOptions { #[structopt( long = "manylinux", raw( - possible_values = r#"&["1", "1-unchecked", "off"]"#, + possible_values = r#"&["1", "1-unchecked", "2010", "2010-unchecked", "off"]"#, case_insensitive = "true", default_value = r#""1""# ) diff --git a/src/target.rs b/src/target.rs index a8bfa56c4..30d1d6322 100644 --- a/src/target.rs +++ b/src/target.rs @@ -23,6 +23,10 @@ pub enum Manylinux { Manylinux1, /// Use the manylinux1 tag but don't check for compliance Manylinux1Unchecked, + /// Use manylinux2010 tag and check for compliance + Manylinux2010, + /// Use the manylinux2010 tag but don't check for compliance + Manylinux2010Unchecked, /// Use the native linux tag Off, } @@ -34,6 +38,8 @@ impl FromStr for Manylinux { match value { "1" => Ok(Manylinux::Manylinux1), "1-unchecked" => Ok(Manylinux::Manylinux1Unchecked), + "2010" => Ok(Manylinux::Manylinux2010), + "2010-unchecked" => Ok(Manylinux::Manylinux2010Unchecked), "off" => Ok(Manylinux::Off), _ => Err("Invalid value for the manylinux option"), } @@ -129,8 +135,14 @@ impl Target { match (&self.os, self.is_64_bit, manylinux) { (&OS::Linux, true, Manylinux::Off) => "linux_x86_64", (&OS::Linux, false, Manylinux::Off) => "linux_i686", - (&OS::Linux, true, _) => "manylinux1_x86_64", - (&OS::Linux, false, _) => "manylinux1_i686", + (&OS::Linux, true, Manylinux::Manylinux1) => "manylinux1_x86_64", + (&OS::Linux, true, Manylinux::Manylinux1Unchecked) => "manylinux1_x86_64", + (&OS::Linux, true, Manylinux::Manylinux2010) => "manylinux2010_x86_64", + (&OS::Linux, true, Manylinux::Manylinux2010Unchecked) => "manylinux2010_x86_64", + (&OS::Linux, false, Manylinux::Manylinux1) => "manylinux1_i686", + (&OS::Linux, false, Manylinux::Manylinux1Unchecked) => "manylinux1_i686", + (&OS::Linux, false, Manylinux::Manylinux2010) => "manylinux2010_i686", + (&OS::Linux, false, Manylinux::Manylinux2010Unchecked) => "manylinux2010_i686", (&OS::Windows, true, _) => "win_amd64", (&OS::Windows, false, _) => "win32", (&OS::Macos, true, _) => "macosx_10_7_x86_64",