Skip to content

Commit

Permalink
Merge pull request #70 from ijl/manylinux2010
Browse files Browse the repository at this point in the history
manylinux2010
  • Loading branch information
konstin authored Jan 24, 2019
2 parents 5e6783f + fc52cbe commit b71e14e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
6 changes: 4 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <out>
The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target
directory
Expand Down Expand Up @@ -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 <out>
The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target
directory
Expand Down
20 changes: 17 additions & 3 deletions src/auditwheel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::Manylinux;
use crate::Target;
use failure::Fail;
use goblin;
use goblin::elf::Elf;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/build_context.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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""#
)
Expand Down
16 changes: 14 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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"),
}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit b71e14e

Please sign in to comment.