Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip auditwheel for non-compliant linux environment automatically #931

Merged
merged 1 commit into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

* Add support for building bin bindings wheels with multiple platform tags in [#928](https://github.com/PyO3/maturin/pull/928)
* Skip auditwheel for non-compliant linux environment automatically in [#931](https://github.com/PyO3/maturin/pull/931)

## [0.12.17] - 2022-05-18

Expand Down
24 changes: 20 additions & 4 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,25 @@ impl BuildContext {
&self,
artifact: &Path,
platform_tag: &[PlatformTag],
python_interpreter: Option<&PythonInterpreter>,
) -> Result<(Policy, Vec<Library>)> {
if self.skip_auditwheel || self.editable {
return Ok((Policy::default(), Vec::new()));
}

if let Some(python_interpreter) = python_interpreter {
if platform_tag.is_empty()
&& self.target.is_linux()
&& !python_interpreter.support_portable_wheels()
{
println!(
"🐍 Skipping auditwheel because {} does not support manylinux/musllinux wheels",
python_interpreter
);
return Ok((Policy::default(), Vec::new()));
}
}

let mut musllinux: Vec<_> = platform_tag
.iter()
.filter(|tag| tag.is_musllinux())
Expand Down Expand Up @@ -454,7 +468,8 @@ impl BuildContext {
python_interpreter,
Some(&self.project_layout.extension_name),
)?;
let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag)?;
let (policy, external_libs) =
self.auditwheel(&artifact, &self.platform_tag, python_interpreter)?;
let platform_tags = if self.platform_tag.is_empty() {
vec![policy.platform_tag()]
} else {
Expand Down Expand Up @@ -528,7 +543,8 @@ impl BuildContext {
Some(python_interpreter),
Some(&self.project_layout.extension_name),
)?;
let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag)?;
let (policy, external_libs) =
self.auditwheel(&artifact, &self.platform_tag, Some(python_interpreter))?;
let platform_tags = if self.platform_tag.is_empty() {
vec![policy.platform_tag()]
} else {
Expand Down Expand Up @@ -624,7 +640,7 @@ impl BuildContext {
pub fn build_cffi_wheel(&self) -> Result<Vec<BuiltWheelMetadata>> {
let mut wheels = Vec::new();
let artifact = self.compile_cdylib(None, None)?;
let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag)?;
let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag, None)?;
let platform_tags = if self.platform_tag.is_empty() {
vec![policy.platform_tag()]
} else {
Expand Down Expand Up @@ -702,7 +718,7 @@ impl BuildContext {
.cloned()
.ok_or_else(|| anyhow!("Cargo didn't build a binary"))?;

let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag)?;
let (policy, external_libs) = self.auditwheel(&artifact, &self.platform_tag, None)?;
let platform_tags = if self.platform_tag.is_empty() {
vec![policy.platform_tag()]
} else {
Expand Down
30 changes: 30 additions & 0 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,36 @@ impl PythonInterpreter {
Ok(ok) => Ok(String::from_utf8(ok.stdout)?),
}
}

/// Whether this Python interpreter support portable manylinux/musllinux wheels
///
/// Returns `true` if we can not decide
pub fn support_portable_wheels(&self) -> bool {
if !self.runnable {
return true;
}
let out = Command::new(&self.executable)
.args(&[
"-m",
"pip",
"debug",
"--verbose",
"--disable-pip-version-check",
])
.output();

match out {
Err(_) => true,
Ok(ok) if !ok.status.success() => true,
Ok(ok) => {
if let Ok(stdout) = String::from_utf8(ok.stdout) {
stdout.contains("manylinux") || stdout.contains("musllinux")
} else {
true
}
}
}
}
}

impl fmt::Display for PythonInterpreter {
Expand Down