From 76a7ea2bf8b9451293c0dd9e28d562644d52786e Mon Sep 17 00:00:00 2001 From: Kevin King <4kevinking@gmail.com> Date: Tue, 14 May 2024 16:28:30 -0700 Subject: [PATCH] sanity check CI Revert "Detect target based on interpreter for pep517 build-wheel" This reverts commit 88bce88064404c1c3342e76ced704e4929cfc47f. --- src/build_options.rs | 11 +---------- src/develop.rs | 20 +++++++++++++++++--- src/target.rs | 22 ---------------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/build_options.rs b/src/build_options.rs index b30caf101..4258e3568 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -551,16 +551,7 @@ impl BuildOptions { target_triple = None; } - let mut target = Target::from_target_triple(target_triple)?; - if !target.user_specified && !universal2 { - if let Some(interpreter) = self.interpreter.first() { - if let Some(detected_target) = - crate::target::detect_arch_from_python(interpreter, &target) - { - target = Target::from_target_triple(Some(detected_target))?; - } - } - } + let target = Target::from_target_triple(target_triple)?; let wheel_dir = match self.out { Some(ref dir) => dir.clone(), diff --git a/src/develop.rs b/src/develop.rs index 19fc727ef..2a948e5e1 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -1,5 +1,5 @@ use crate::build_options::CargoOptions; -use crate::target::detect_arch_from_python; +use crate::target::Arch; use crate::BuildContext; use crate::BuildOptions; use crate::PlatformTag; @@ -307,8 +307,22 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> { // check python platform and architecture if !target.user_specified { - if let Some(detected_target) = detect_arch_from_python(&python, &target) { - target_triple = Some(detected_target); + 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"), } } diff --git a/src/target.rs b/src/target.rs index ab651714b..177b8453d 100644 --- a/src/target.rs +++ b/src/target.rs @@ -8,7 +8,6 @@ use std::env; use std::fmt; use std::path::Path; use std::path::PathBuf; -use std::process::Command; use std::str; use target_lexicon::{Architecture, Environment, Triple}; use tracing::error; @@ -619,24 +618,3 @@ fn rustc_version_meta() -> Result { })?; Ok(meta) } - -pub(crate) fn detect_arch_from_python(python: &PathBuf, target: &Target) -> Option { - 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 { - return Some("x86_64-apple-darwin".to_string()); - } else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 { - return Some("aarch64-apple-darwin".to_string()); - } - } - } - _ => eprintln!("⚠️ Warning: Failed to determine python platform"), - } - None -}