Skip to content

Commit

Permalink
Fix maturin develop for arm64 Python on M1 Mac when default toolcha…
Browse files Browse the repository at this point in the history
…in is x86_64
  • Loading branch information
messense committed Jun 21, 2022
1 parent cecd677 commit 5daa592
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/develop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::build_options::CargoOptions;
use crate::target::Arch;
use crate::BuildOptions;
use crate::PlatformTag;
use crate::PythonInterpreter;
Expand All @@ -21,8 +22,28 @@ pub fn develop(
strip: bool,
extras: Vec<String>,
) -> Result<()> {
let target = Target::from_target_triple(None)?;
let mut target = Target::from_target_triple(None)?;
let python = target.get_venv_python(&venv_dir);

// check python platform and architecture
match Command::new(&python)
.arg("-c")
.arg("import sysconfig; print(sysconfig.get_platform(), end='')")
.output()
{
Ok(output) if output.status.success() => {
let platform = String::from_utf8_lossy(&output.stdout);
if platform.contains("macos") {
if platform.contains("x86_64") && target.target_arch() != Arch::X86_64 {
target = Target::from_target_triple(Some("x86_64-apple-darwin".to_string()))?;
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
target = Target::from_target_triple(Some("aarch64-apple-darwin".to_string()))?;
}
}
}
_ => eprintln!("⚠️ Warning: Failed to determinate python platform"),
}

// Store wheel in a unique location so we don't get name clashes with parallel runs
let wheel_dir = TempDir::new().context("Failed to create temporary directory")?;

Expand Down

0 comments on commit 5daa592

Please sign in to comment.