From 7c43487b188c0b14d20b7e78ddf7075e21b95cc2 Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 18 Feb 2021 14:46:25 +0800 Subject: [PATCH] Change manylinux default version based on target arch --- Changelog.md | 4 ++++ Readme.md | 8 ++++++-- src/build_options.rs | 13 +++++++++---- src/develop.rs | 2 +- src/target.rs | 10 ++++++++++ 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 329fbf3fb..aff9b6dd6 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 + +* Change manylinux default version based on target arch by messense in [#424](https://github.com/PyO3/maturin/pull/424) + ## 0.9.4 - 2021-02-18 * Fix building a bin with musl diff --git a/Readme.md b/Readme.md index 596ea91d6..c9f23da66 100644 --- a/Readme.md +++ b/Readme.md @@ -244,7 +244,9 @@ OPTIONS: `off` (for the native linux tag). Note that manylinux1 is unsupported by the rust compiler. Wheels with the native tag will be rejected by pypi, unless they are separately validated by `auditwheel`. - This option is ignored on all non-linux platforms [default: 2010] [possible values: 2010, 2014, off] + The default is the lowest supported value for a target, which is 2010 for x86 and 2014 for arm and powerpc. + + This option is ignored on all non-linux platforms [possible values: 2010, 2014, off] -o, --out The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory @@ -305,7 +307,9 @@ OPTIONS: `off` (for the native linux tag). Note that manylinux1 is unsupported by the rust compiler. Wheels with the native tag will be rejected by pypi, unless they are separately validated by `auditwheel`. - This option is ignored on all non-linux platforms [default: 2010] [possible values: 2010, 2014, off] + The default is the lowest supported value for a target, which is 2010 for x86 and 2014 for arm and powerpc. + + This option is ignored on all non-linux platforms [possible values: 2010, 2014, 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/build_options.rs b/src/build_options.rs index 1093d084e..4b8b95469 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -24,14 +24,16 @@ pub struct BuildOptions { /// will be rejected by pypi, unless they are separately validated by /// `auditwheel`. /// + /// The default is the lowest supported value for a target, which is 2010 for x86 and 2014 for + /// arm and powerpc. + /// /// This option is ignored on all non-linux platforms #[structopt( long, possible_values = &["2010", "2014", "off"], case_insensitive = true, - default_value = "2010" )] - pub manylinux: Manylinux, + pub manylinux: Option, #[structopt(short, long)] /// The python versions to build wheels for, given as the names of the /// interpreters. Uses autodiscovery if not explicitly set. @@ -77,7 +79,7 @@ pub struct BuildOptions { impl Default for BuildOptions { fn default() -> Self { BuildOptions { - manylinux: Manylinux::Manylinux2010, + manylinux: None, interpreter: Some(vec![]), bindings: None, manifest_path: PathBuf::from("Cargo.toml"), @@ -161,6 +163,9 @@ impl BuildOptions { } let target = Target::from_target_triple(self.target.clone())?; + let manylinux = self + .manylinux + .unwrap_or_else(|| target.get_default_manylinux_tag()); let wheel_dir = match self.out { Some(ref dir) => dir.clone(), @@ -191,7 +196,7 @@ impl BuildOptions { release, strip, skip_auditwheel: self.skip_auditwheel, - manylinux: self.manylinux, + manylinux, cargo_extra_args, rustc_extra_args, interpreter, diff --git a/src/develop.rs b/src/develop.rs index 89108a108..16a40f714 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -27,7 +27,7 @@ pub fn develop( let python = target.get_venv_python(&venv_dir); let build_options = BuildOptions { - manylinux: Manylinux::Off, + manylinux: Some(Manylinux::Off), interpreter: Some(vec![target.get_python()]), bindings, manifest_path: manifest_file.to_path_buf(), diff --git a/src/target.rs b/src/target.rs index 8b395cb88..76e6fef05 100644 --- a/src/target.rs +++ b/src/target.rs @@ -194,6 +194,16 @@ impl Target { } } + /// Returns the default Manylinux tag for this architecture + pub fn get_default_manylinux_tag(&self) -> Manylinux { + match self.arch { + Arch::AARCH64 | Arch::ARMV7L | Arch::POWERPC64 | Arch::POWERPC64LE => { + Manylinux::Manylinux2014 + } + Arch::X86 | Arch::X86_64 => Manylinux::Manylinux2010, + } + } + /// 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 { match (&self.os, &self.arch) {