From 7d4b39941ad3582190b553c9023bcc758113567e Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 29 Apr 2021 17:10:30 +0800 Subject: [PATCH 1/3] Add manylinux_2_27 support --- Changelog.md | 4 ++ Readme.md | 20 +++++----- src/auditwheel/audit.rs | 2 +- src/auditwheel/manylinux.rs | 64 +++++++++++++++++++++---------- src/auditwheel/policy.json | 76 ++++++++++++++++++++++++++++++++----- src/auditwheel/policy.rs | 38 +++++++++---------- src/build_options.rs | 7 ++-- src/target.rs | 4 +- 8 files changed, 150 insertions(+), 65 deletions(-) diff --git a/Changelog.md b/Changelog.md index 848d01933..271b50723 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/Readme.md b/Readme.md index 9aa88471c..c85a190fb 100644 --- a/Readme.md +++ b/Readme.md @@ -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 - 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 The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory @@ -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 - 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 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/audit.rs b/src/auditwheel/audit.rs index f8000a02f..f2a666e54 100644 --- a/src/auditwheel/audit.rs +++ b/src/auditwheel/audit.rs @@ -298,7 +298,7 @@ pub fn auditwheel_rs( println!( "📦 Wheel is eligible for a higher priority tag. \ You requested {} but this wheel is eligible for {}", - policy.name, highest_policy.name, + policy, highest_policy, ); } } diff --git a/src/auditwheel/manylinux.rs b/src/auditwheel/manylinux.rs index da94bbd4e..30fa7718d 100644 --- a/src/auditwheel/manylinux.rs +++ b/src/auditwheel/manylinux.rs @@ -5,26 +5,42 @@ 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 } + } + + /// `manylinux1` aka `manylinux_2_5` + pub fn manylinux1() -> Self { + Self::Manylinux { x: 2, y: 5 } + } + + /// `manylinux2010` aka `manylinux_2_12` + pub fn manylinux2010() -> Self { + Self::Manylinux { x: 2, y: 12 } + } + + /// `manylinux2014` aka `manylinux_2_17` + 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"), } } @@ -35,13 +51,23 @@ impl FromStr for Manylinux { fn from_str(value: &str) -> anyhow::Result { 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::manylinux1()), + "2010" | "manylinux2010" => Ok(Manylinux::manylinux2010()), + "2014" | "manylinux2014" => Ok(Manylinux::manylinux2014()), + _ => { + let value = value.strip_prefix("manylinux_").unwrap_or(value); + let mut parts = value.split('_'); + let x = parts + .next() + .and_then(|x| x.parse::().ok()) + .ok_or("invalid manylinux option")?; + let y = parts + .next() + .and_then(|y| y.parse::().ok()) + .ok_or("invalid manylinux option")?; + Ok(Manylinux::new(x, y)) + } } } } diff --git a/src/auditwheel/policy.json b/src/auditwheel/policy.json index 7c9b722fc..a8efca23f 100644 --- a/src/auditwheel/policy.json +++ b/src/auditwheel/policy.json @@ -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": { @@ -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", @@ -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": { @@ -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": { @@ -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": { @@ -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" ]} ] diff --git a/src/auditwheel/policy.rs b/src/auditwheel/policy.rs index 6a608dba0..c3f0a5150 100644 --- a/src/auditwheel/policy.rs +++ b/src/auditwheel/policy.rs @@ -21,6 +21,8 @@ pub static POLICIES: Lazy> = Lazy::new(|| { pub struct Policy { /// manylinux platform tag name pub name: String, + /// manylinux platform tag aliases + pub aliases: Vec, /// policy priority. Tags supporting more platforms have higher priority pub priority: i64, /// platform architecture to symbol versions map @@ -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(",") + )) + } } } @@ -62,7 +72,10 @@ impl Policy { /// Get policy by it's manylinux platform tag name pub fn from_name(name: &str) -> Option { - 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 @@ -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); @@ -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()); - } - } } diff --git a/src/build_options.rs b/src/build_options.rs index 675af4296..494359b7b 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -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`. /// @@ -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, diff --git a/src/target.rs b/src/target.rs index 15afdee5c..f3df17fd9 100644 --- a/src/target.rs +++ b/src/target.rs @@ -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(), } } From 602e8552096f65b549dce5ee4f17c6eb0804c86b Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 6 May 2021 14:49:59 +0800 Subject: [PATCH 2/3] Pass Manylinux by value --- src/build_context.rs | 22 +++++++++------------- src/develop.rs | 6 +++--- src/main.rs | 6 +++--- src/python_interpreter.rs | 2 +- src/target.rs | 14 +++++++------- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/build_context.rs b/src/build_context.rs index 18df8380e..9f9af6806 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -233,11 +233,11 @@ impl BuildContext { fn write_binding_wheel_abi3( &self, artifact: &Path, - manylinux: &Manylinux, + manylinux: Manylinux, major: u8, min_minor: u8, ) -> Result { - let platform = self.target.get_platform_tag(&manylinux, self.universal2); + let platform = self.target.get_platform_tag(manylinux, self.universal2); let tag = format!("cp{}{}-abi3-{}", major, min_minor, platform); let mut writer = WheelWriter::new( @@ -277,7 +277,7 @@ impl BuildContext { let artifact = self.compile_cdylib(python_interpreter, Some(&self.module_name))?; let policy = self.auditwheel(python_interpreter, &artifact, self.manylinux)?; let (wheel_path, tag) = - self.write_binding_wheel_abi3(&artifact, &policy.manylinux_tag(), major, min_minor)?; + self.write_binding_wheel_abi3(&artifact, policy.manylinux_tag(), major, min_minor)?; println!( "📦 Built wheel for abi3 Python ≥ {}.{} to {}", @@ -294,7 +294,7 @@ impl BuildContext { &self, python_interpreter: &PythonInterpreter, artifact: &Path, - manylinux: &Manylinux, + manylinux: Manylinux, ) -> Result { let tag = python_interpreter.get_tag(manylinux, self.universal2); @@ -338,7 +338,7 @@ impl BuildContext { self.compile_cdylib(Some(&python_interpreter), Some(&self.module_name))?; let policy = self.auditwheel(Some(&python_interpreter), &artifact, self.manylinux)?; let (wheel_path, tag) = - self.write_binding_wheel(python_interpreter, &artifact, &policy.manylinux_tag())?; + self.write_binding_wheel(python_interpreter, &artifact, policy.manylinux_tag())?; println!( "📦 Built wheel for {} {}.{}{} to {}", python_interpreter.interpreter_kind, @@ -385,7 +385,7 @@ impl BuildContext { fn write_cffi_wheel( &self, artifact: &Path, - manylinux: &Manylinux, + manylinux: Manylinux, ) -> Result { let (tag, tags) = self.target.get_universal_tags(manylinux, self.universal2); @@ -411,7 +411,7 @@ impl BuildContext { let mut wheels = Vec::new(); let artifact = self.compile_cdylib(None, None)?; let policy = self.auditwheel(None, &artifact, self.manylinux)?; - let (wheel_path, tag) = self.write_cffi_wheel(&artifact, &policy.manylinux_tag())?; + let (wheel_path, tag) = self.write_cffi_wheel(&artifact, policy.manylinux_tag())?; println!("📦 Built wheel to {}", wheel_path.display()); wheels.push((wheel_path, tag)); @@ -419,11 +419,7 @@ impl BuildContext { Ok(wheels) } - fn write_bin_wheel( - &self, - artifact: &Path, - manylinux: &Manylinux, - ) -> Result { + fn write_bin_wheel(&self, artifact: &Path, manylinux: Manylinux) -> Result { let (tag, tags) = self.target.get_universal_tags(manylinux, self.universal2); if !self.scripts.is_empty() { @@ -471,7 +467,7 @@ impl BuildContext { let policy = self.auditwheel(None, &artifact, self.manylinux)?; - let (wheel_path, tag) = self.write_bin_wheel(&artifact, &policy.manylinux_tag())?; + let (wheel_path, tag) = self.write_bin_wheel(&artifact, policy.manylinux_tag())?; println!("📦 Built wheel to {}", wheel_path.display()); wheels.push((wheel_path, tag)); diff --git a/src/develop.rs b/src/develop.rs index e315ae17a..24a89227b 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -164,16 +164,16 @@ pub fn develop( // We skip running auditwheel and simply tag as linux let tags = match build_context.bridge { BridgeModel::Bindings(_) => { - vec![build_context.interpreter[0].get_tag(&Manylinux::Off, build_context.universal2)] + vec![build_context.interpreter[0].get_tag(Manylinux::Off, build_context.universal2)] } BridgeModel::BindingsAbi3(major, minor) => { - let platform = target.get_platform_tag(&Manylinux::Off, build_context.universal2); + let platform = target.get_platform_tag(Manylinux::Off, build_context.universal2); vec![format!("cp{}{}-abi3-{}", major, minor, platform)] } BridgeModel::Bin | BridgeModel::Cffi => { build_context .target - .get_universal_tags(&Manylinux::Off, build_context.universal2) + .get_universal_tags(Manylinux::Off, build_context.universal2) .1 } }; diff --git a/src/main.rs b/src/main.rs index 6c894db10..57a9eaae3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -351,18 +351,18 @@ fn pep517(subcommand: Pep517Command) -> Result<()> { // Since afaik all other PEP 517 backends also return linux tagged wheels, we do so too let tags = match context.bridge { BridgeModel::Bindings(_) => { - vec![context.interpreter[0].get_tag(&Manylinux::Off, context.universal2)] + vec![context.interpreter[0].get_tag(Manylinux::Off, context.universal2)] } BridgeModel::BindingsAbi3(major, minor) => { let platform = context .target - .get_platform_tag(&Manylinux::Off, context.universal2); + .get_platform_tag(Manylinux::Off, context.universal2); vec![format!("cp{}{}-abi3-{}", major, minor, platform)] } BridgeModel::Bin | BridgeModel::Cffi => { context .target - .get_universal_tags(&Manylinux::Off, context.universal2) + .get_universal_tags(Manylinux::Off, context.universal2) .1 } }; diff --git a/src/python_interpreter.rs b/src/python_interpreter.rs index a9c2c86f2..535a31750 100644 --- a/src/python_interpreter.rs +++ b/src/python_interpreter.rs @@ -339,7 +339,7 @@ impl PythonInterpreter { /// Don't ask me why or how, this is just what setuptools uses so I'm also going to use /// /// If abi3 is true, cpython wheels use the generic abi3 with the given version as minimum - pub fn get_tag(&self, manylinux: &Manylinux, universal2: bool) -> String { + pub fn get_tag(&self, manylinux: Manylinux, universal2: bool) -> String { match self.interpreter_kind { InterpreterKind::CPython => { let platform = self.target.get_platform_tag(manylinux, universal2); diff --git a/src/target.rs b/src/target.rs index f3df17fd9..1c5a473dc 100644 --- a/src/target.rs +++ b/src/target.rs @@ -139,8 +139,8 @@ impl Target { }) } - /// Returns the platform part of the tag for the wheel name for cffi wheels - pub fn get_platform_tag(&self, manylinux: &Manylinux, universal2: bool) -> String { + /// Returns the platform part of the tag for the wheel name + pub fn get_platform_tag(&self, manylinux: Manylinux, universal2: bool) -> String { match (&self.os, &self.arch) { (Os::FreeBsd, Arch::X86_64) => { let info = match PlatformInfo::new() { @@ -256,10 +256,10 @@ impl Target { } /// Returns the tags for the WHEEL file for cffi wheels - pub fn get_py3_tags(&self, manylinux: &Manylinux, universal2: bool) -> Vec { + pub fn get_py3_tags(&self, manylinux: Manylinux, universal2: bool) -> Vec { vec![format!( "py3-none-{}", - self.get_platform_tag(&manylinux, universal2) + self.get_platform_tag(manylinux, universal2) )] } @@ -324,14 +324,14 @@ impl Target { /// Returns the tags for the platform without python version pub fn get_universal_tags( &self, - manylinux: &Manylinux, + manylinux: Manylinux, universal2: bool, ) -> (String, Vec) { let tag = format!( "py3-none-{platform}", - platform = self.get_platform_tag(&manylinux, universal2) + platform = self.get_platform_tag(manylinux, universal2) ); - let tags = self.get_py3_tags(&manylinux, universal2); + let tags = self.get_py3_tags(manylinux, universal2); (tag, tags) } } From fa5066d62488462a71449b2d598b7d89a30da009 Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 6 May 2021 14:49:48 +0800 Subject: [PATCH 3/3] cargo update --- Cargo.lock | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd6f53ec7..32941545c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -344,10 +344,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" [[package]] -name = "cpuid-bool" -version = "0.1.2" +name = "cpufeatures" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +checksum = "5cd5a7748210e7ec1a9696610b1015e6e31fbf58f77a160801f124bd1c36592a" [[package]] name = "crc32fast" @@ -621,9 +621,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" dependencies = [ "bytes", "fnv", @@ -939,9 +939,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "mime" @@ -1384,9 +1384,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" dependencies = [ "bitflags", ] @@ -1403,9 +1403,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.6" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "ce5f1ceb7f74abbce32601642fcf8e8508a8a8991e0621c7d750295b9095702b" dependencies = [ "aho-corasick", "memchr", @@ -1414,9 +1414,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "remove_dir_all" @@ -1490,9 +1490,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" [[package]] name = "rustls" @@ -1655,13 +1655,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +checksum = "d8f6b75b17576b792bef0db1bcc4b8b8bcdf9506744cf34b974195487af6cff2" dependencies = [ "block-buffer", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest", "opaque-debug", ] @@ -1732,9 +1732,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -1897,9 +1897,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" dependencies = [ "cfg-if", "pin-project-lite", @@ -1908,9 +1908,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" dependencies = [ "lazy_static", ] @@ -1974,9 +1974,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unindent"