Skip to content

Commit

Permalink
Add manylinux_2_27 support
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Apr 29, 2021
1 parent cd0b0ae commit 769711e
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 64 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (for the cli, not for the crate).

## Unreleased

* Add `manylinux_2_27` support in [#521](https://github.com/PyO3/maturin/pull/521)

## 0.10.4 - 2021-04-28

* Interpreter search now uses python 3.6 to 3.12 in [#495](https://github.com/PyO3/maturin/pull/495)
Expand Down
20 changes: 10 additions & 10 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ OPTIONS:
The python versions to build wheels for, given as the names of the interpreters. Uses autodiscovery if not
explicitly set
--manylinux <manylinux>
Control the platform tag on linux. Options are `2010` (for manylinux2010), `2014` (for manylinux2014),
`2_24` (for manylinux_2_24) and `off` (for the native linux tag). Note that manylinux1 is unsupported by the
rust compiler. Wheels with the native `linux` tag will be rejected by pypi, unless they are separately
validated by `auditwheel`.
Control the platform tag on linux. Options are `2010`/`2_12` (for manylinux2010), `2014`/`2_17` (for
manylinux2014), `2_24` (for manylinux_2_24), `2_27` (for manylinux_2_27) and `off` (for the native linux
tag). Note that manylinux1 is unsupported by the rust compiler. Wheels with the native `linux` tag will be
rejected by pypi, unless they are separately validated by `auditwheel`.
The default is the lowest compatible, of plain `linux` if nothing matched
This option is ignored on all non-linux platforms [possible values: 2010, 2014, 2_24, off]
This option is ignored on all non-linux platforms [possible values: 2010, 2014, 2_12, 2_17, 2_24, 2_27, 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 @@ -311,14 +311,14 @@ OPTIONS:
The python versions to build wheels for, given as the names of the interpreters. Uses autodiscovery if not
explicitly set
--manylinux <manylinux>
Control the platform tag on linux. Options are `2010` (for manylinux2010), `2014` (for manylinux2014),
`2_24` (for manylinux_2_24) and `off` (for the native linux tag). Note that manylinux1 is unsupported by the
rust compiler. Wheels with the native `linux` tag will be rejected by pypi, unless they are separately
validated by `auditwheel`.
Control the platform tag on linux. Options are `2010`/`2_12` (for manylinux2010), `2014`/`2_17` (for
manylinux2014), `2_24` (for manylinux_2_24), `2_27` (for manylinux_2_27) and `off` (for the native linux
tag). Note that manylinux1 is unsupported by the rust compiler. Wheels with the native `linux` tag will be
rejected by pypi, unless they are separately validated by `auditwheel`.
The default is the lowest compatible, of plain `linux` if nothing matched
This option is ignored on all non-linux platforms [possible values: 2010, 2014, 2_24, off]
This option is ignored on all non-linux platforms [possible values: 2010, 2014, 2_12, 2_17, 2_24, 2_27, 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
59 changes: 40 additions & 19 deletions src/auditwheel/manylinux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,37 @@ use std::str::FromStr;
/// Decides how to handle manylinux compliance
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Copy)]
pub enum Manylinux {
/// Use the manylinux1 tag
Manylinux1,
/// Use the manylinux2010 tag
Manylinux2010,
/// Use the manylinux2014 tag
Manylinux2014,
/// Use the manylinux_2_24 tag
#[allow(non_camel_case_types)]
Manylinux_2_24,
/// Use the manylinux_x_y tag
Manylinux {
/// GLIBC version major
x: u16,
/// GLIBC version minor
y: u16,
},
/// Use the native linux tag
Off,
}

impl Manylinux {
fn new(x: u16, y: u16) -> Self {
Self::Manylinux { x, y }
}

/// manylinux2010
pub fn manylinux2010() -> Self {
Self::Manylinux { x: 2, y: 12 }
}

/// manylinux2014
pub fn manylinux2014() -> Self {
Self::Manylinux { x: 2, y: 17 }
}
}

impl fmt::Display for Manylinux {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Manylinux::Manylinux1 => write!(f, "manylinux1"),
Manylinux::Manylinux2010 => write!(f, "manylinux2010"),
Manylinux::Manylinux2014 => write!(f, "manylinux2014"),
Manylinux::Manylinux_2_24 => write!(f, "manylinux_2_24"),
Manylinux::Manylinux { x, y } => write!(f, "manylinux_{}_{}", x, y),
Manylinux::Off => write!(f, "linux"),
}
}
Expand All @@ -35,13 +46,23 @@ impl FromStr for Manylinux {

fn from_str(value: &str) -> anyhow::Result<Self, Self::Err> {
match value {
"auto" => Ok(Manylinux::Manylinux1),
"1" | "manylinux1" => Ok(Manylinux::Manylinux1),
"2010" | "manylinux2010" => Ok(Manylinux::Manylinux2010),
"2014" | "manylinux2014" => Ok(Manylinux::Manylinux2014),
"2_24" | "manylinux_2_24" => Ok(Manylinux::Manylinux_2_24),
"off" | "linux" => Ok(Manylinux::Off),
_ => Err("Invalid value for the manylinux option"),
"auto" | "1" | "manylinux1" => Ok(Manylinux::new(2, 5)),
"2010" | "manylinux2010" => Ok(Manylinux::new(2, 12)),
"2014" | "manylinux2014" => Ok(Manylinux::new(2, 17)),
_ => {
let value = value.strip_prefix("manylinux_").unwrap_or(value);
let mut parts = value.split('_');
let x = parts
.next()
.and_then(|x| x.parse::<u16>().ok())
.ok_or("invalid manylinux option")?;
let y = parts
.next()
.and_then(|y| y.parse::<u16>().ok())
.ok_or("invalid manylinux option")?;
Ok(Manylinux::new(x, y))
}
}
}
}
76 changes: 67 additions & 9 deletions src/auditwheel/policy.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[
{"name": "linux",
"aliases": [],
"priority": 0,
"symbol_versions": {},
"lib_whitelist": []
},
{"name": "manylinux1",
{"name": "manylinux_2_5",
"aliases": ["manylinux1"],
"priority": 100,
"symbol_versions": {
"i686": {
"CXXABI": ["1.3", "1.3.1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0"],
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "4.0.0", "4.2.0"],
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8"]
},
"x86_64": {
Expand All @@ -21,7 +23,6 @@
}
},
"lib_whitelist": [
"libpanelw.so.5", "libncursesw.so.5",
"libgcc_s.so.1",
"libstdc++.so.6",
"libm.so.6", "libdl.so.2", "librt.so.1",
Expand All @@ -30,7 +31,8 @@
"libSM.so.6", "libGL.so.1", "libgobject-2.0.so.0",
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2"
]},
{"name": "manylinux2010",
{"name": "manylinux_2_12",
"aliases": ["manylinux2010"],
"priority": 90,
"symbol_versions": {
"i686": {
Expand All @@ -53,9 +55,11 @@
"libc.so.6", "libnsl.so.1", "libutil.so.1", "libpthread.so.0",
"libX11.so.6", "libXext.so.6", "libXrender.so.1", "libICE.so.6",
"libSM.so.6", "libGL.so.1", "libgobject-2.0.so.0",
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2"
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2",
"libexpat.so.1"
]},
{"name": "manylinux2014",
{"name": "manylinux_2_17",
"aliases": ["manylinux2014"],
"priority": 80,
"symbol_versions": {
"i686": {
Expand Down Expand Up @@ -108,9 +112,11 @@
"libc.so.6", "libnsl.so.1", "libutil.so.1", "libpthread.so.0",
"libX11.so.6", "libXext.so.6", "libXrender.so.1", "libICE.so.6",
"libSM.so.6", "libGL.so.1", "libgobject-2.0.so.0",
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2"
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2",
"libexpat.so.1"
]},
{"name": "manylinux_2_24",
"aliases": [],
"priority": 70,
"symbol_versions": {
"i686": {
Expand Down Expand Up @@ -157,6 +163,58 @@
"libc.so.6", "libnsl.so.1", "libutil.so.1", "libpthread.so.0",
"libX11.so.6", "libXext.so.6", "libXrender.so.1", "libICE.so.6",
"libSM.so.6", "libGL.so.1", "libgobject-2.0.so.0",
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2"
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2",
"libexpat.so.1"
]},
{"name": "manylinux_2_27",
"aliases": [],
"priority": 65,
"symbol_versions": {
"i686": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "FLOAT128", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "4.0.0", "4.2.0", "4.3.0", "4.4.0", "4.5.0", "4.7.0", "4.8.0", "7.0.0"],
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17", "2.18", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24"]
},
"x86_64": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "FLOAT128", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.7.0", "4.8.0", "7.0.0"],
"GLIBC": ["2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17", "2.18", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24"]
},
"aarch64": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.5.0", "4.7.0", "7.0.0"],
"GLIBC": ["2.0", "2.17", "2.18", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24"]
},
"ppc64le": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "LDBL_1.3", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.7.0", "7.0.0"],
"GLIBC": ["2.0", "2.17", "2.18", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24", "LDBL_3.4", "LDBL_3.4.10", "LDBL_3.4.21", "LDBL_3.4.7"]
},
"s390x": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "LDBL_1.3", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.1.0", "4.2.0", "4.3.0", "4.7.0", "7.0.0"],
"GLIBC": ["2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17", "2.18", "2.19", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24", "LDBL_3.4", "LDBL_3.4.10", "LDBL_3.4.21", "LDBL_3.4.7"]
},
"armv7l": {
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "1.3.8", "1.3.9", "1.3.10", "1.3.11", "ARM_1.3.3", "TM_1"],
"GCC": ["3.0", "3.3", "3.3.1", "3.3.4", "3.4", "3.4.2", "3.5", "4.0.0", "4.2.0", "4.3.0", "4.7.0", "7.0.0"],
"GLIBC": ["2.0", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17", "2.18", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27"],
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "3.4.20", "3.4.21", "3.4.22", "3.4.23", "3.4.24"]
}
},
"lib_whitelist": [
"libgcc_s.so.1",
"libstdc++.so.6",
"libm.so.6", "libdl.so.2", "librt.so.1",
"libc.so.6", "libnsl.so.1", "libutil.so.1", "libpthread.so.0",
"libX11.so.6", "libXext.so.6", "libXrender.so.1", "libICE.so.6",
"libSM.so.6", "libGL.so.1", "libgobject-2.0.so.0",
"libgthread-2.0.so.0", "libglib-2.0.so.0", "libresolv.so.2",
"libexpat.so.1"
]}
]
38 changes: 17 additions & 21 deletions src/auditwheel/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub static POLICIES: Lazy<Vec<Policy>> = Lazy::new(|| {
pub struct Policy {
/// manylinux platform tag name
pub name: String,
/// manylinux platform tag aliases
pub aliases: Vec<String>,
/// policy priority. Tags supporting more platforms have higher priority
pub priority: i64,
/// platform architecture to symbol versions map
Expand All @@ -39,7 +41,15 @@ impl Default for Policy {

impl Display for Policy {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(&self.name)
if self.aliases.is_empty() {
f.write_str(&self.name)
} else {
f.write_fmt(format_args!(
"{}(aka {})",
&self.name,
self.aliases.join(",")
))
}
}
}

Expand All @@ -62,7 +72,10 @@ impl Policy {

/// Get policy by it's manylinux platform tag name
pub fn from_name(name: &str) -> Option<Self> {
POLICIES.iter().find(|p| p.name == name).cloned()
POLICIES
.iter()
.find(|p| p.name == name || p.aliases.iter().any(|alias| alias == name))
.cloned()
}

/// Get policy by it's priority
Expand All @@ -77,11 +90,11 @@ mod test {

#[test]
fn test_load_policy() {
let linux = POLICIES.iter().find(|p| p.name == "linux").unwrap();
let linux = Policy::from_name("linux").unwrap();
assert!(linux.symbol_versions.is_empty());
assert!(linux.lib_whitelist.is_empty());

let manylinux2010 = POLICIES.iter().find(|p| p.name == "manylinux2010").unwrap();
let manylinux2010 = Policy::from_name("manylinux2010").unwrap();
assert!(manylinux2010.lib_whitelist.contains("libc.so.6"));
let symbol_version = &manylinux2010.symbol_versions["x86_64"];
assert_eq!(symbol_version["CXXABI"].len(), 4);
Expand All @@ -97,21 +110,4 @@ mod test {
let _tag = policy.manylinux_tag();
}
}

#[test]
fn test_policy_from_name() {
use crate::auditwheel::Manylinux;

let tags = &[
Manylinux::Manylinux1,
Manylinux::Manylinux2010,
Manylinux::Manylinux2014,
Manylinux::Manylinux_2_24,
Manylinux::Off,
];
for manylinux in tags {
let policy = Policy::from_name(&manylinux.to_string());
assert!(policy.is_some());
}
}
}
7 changes: 4 additions & 3 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ use structopt::StructOpt;
#[derive(Debug, Serialize, Deserialize, StructOpt, Clone, Eq, PartialEq)]
#[serde(default)]
pub struct BuildOptions {
/// Control the platform tag on linux. Options are `2010` (for manylinux2010),
/// `2014` (for manylinux2014), `2_24` (for manylinux_2_24) and `off` (for the native linux tag).
/// Control the platform tag on linux. Options are `2010`/`2_12` (for manylinux2010),
/// `2014`/`2_17` (for manylinux2014), `2_24` (for manylinux_2_24), `2_27` (for manylinux_2_27)
/// and `off` (for the native linux tag).
/// Note that manylinux1 is unsupported by the rust compiler. Wheels with the native `linux` tag
/// will be rejected by pypi, unless they are separately validated by `auditwheel`.
///
Expand All @@ -30,7 +31,7 @@ pub struct BuildOptions {
/// This option is ignored on all non-linux platforms
#[structopt(
long,
possible_values = &["2010", "2014", "2_24", "off"],
possible_values = &["2010", "2014", "2_12", "2_17", "2_24", "2_27", "off"],
case_insensitive = true,
)]
pub manylinux: Option<Manylinux>,
Expand Down
4 changes: 2 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ impl Target {
pub fn get_default_manylinux_tag(&self) -> Manylinux {
match self.arch {
Arch::Aarch64 | Arch::Armv7L | Arch::Powerpc64 | Arch::Powerpc64Le | Arch::S390X => {
Manylinux::Manylinux2014
Manylinux::manylinux2014()
}
Arch::X86 | Arch::X86_64 => Manylinux::Manylinux2010,
Arch::X86 | Arch::X86_64 => Manylinux::manylinux2010(),
}
}

Expand Down

0 comments on commit 769711e

Please sign in to comment.