Skip to content

Commit

Permalink
Respect user specified Rust target in maturin develop
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jul 19, 2022
1 parent 0d9d09d commit 823eafd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add 64-bit RISC-V support by felixonmars in [#1001](https://github.com/PyO3/maturin/pull/1001)
* Add support for invoking with `python3 -m maturin` in [#1008](https://github.com/PyO3/maturin/pull/1008)
* Fix detection of optional dependencies when declaring `features` in `pyproject.toml` in [#1014](https://github.com/PyO3/maturin/pull/1014)
* Respect user specified Rust target in `maturin develop` in [#1016](https://github.com/PyO3/maturin/pull/1016)

## [0.13.0] - 2022-07-09

Expand Down
32 changes: 17 additions & 15 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,29 @@ pub fn develop(
strip: bool,
extras: Vec<String>,
) -> Result<()> {
let target = Target::from_target_triple(None)?;
let mut target_triple = None;
let mut target_triple = cargo_options.target.as_ref().map(|x| x.to_string());
let target = Target::from_target_triple(cargo_options.target)?;
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_triple = Some("x86_64-apple-darwin".to_string());
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
target_triple = Some("aarch64-apple-darwin".to_string());
if !target.user_specified {
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_triple = Some("x86_64-apple-darwin".to_string());
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
target_triple = Some("aarch64-apple-darwin".to_string());
}
}
}
_ => eprintln!("⚠️ Warning: Failed to determine python platform"),
}
_ => eprintln!("⚠️ Warning: Failed to determine python platform"),
}

// Store wheel in a unique location so we don't get name clashes with parallel runs
Expand Down

0 comments on commit 823eafd

Please sign in to comment.