-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add support for macOS universal2 wheel #403
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ enum Arch { | |
ARMV7L, | ||
POWERPC64LE, | ||
POWERPC64, | ||
Universal2, | ||
X86, | ||
X86_64, | ||
} | ||
|
@@ -69,6 +70,7 @@ impl fmt::Display for Arch { | |
Arch::ARMV7L => write!(f, "armv7l"), | ||
Arch::POWERPC64LE => write!(f, "ppc64le"), | ||
Arch::POWERPC64 => write!(f, "ppc64"), | ||
Arch::Universal2 => write!(f, "universal2"), | ||
Arch::X86 => write!(f, "i686"), | ||
Arch::X86_64 => write!(f, "x86_64"), | ||
} | ||
|
@@ -108,7 +110,13 @@ impl Target { | |
platforms::target::Arch::X86_64 => Arch::X86_64, | ||
platforms::target::Arch::X86 => Arch::X86, | ||
platforms::target::Arch::ARM => Arch::ARMV7L, | ||
platforms::target::Arch::AARCH64 => Arch::AARCH64, | ||
platforms::target::Arch::AARCH64 => { | ||
if os == OS::Macos { | ||
Arch::Universal2 // macOS with Apple Silicon | ||
} else { | ||
Arch::AARCH64 | ||
} | ||
} | ||
platforms::target::Arch::POWERPC64 | ||
if platform.target_triple.starts_with("powerpc64-") => | ||
{ | ||
|
@@ -126,6 +134,7 @@ impl Target { | |
match (&os, &arch) { | ||
(OS::FreeBSD, Arch::AARCH64) => bail!("aarch64 is not supported for FreeBSD"), | ||
(OS::FreeBSD, Arch::ARMV7L) => bail!("armv7l is not supported for FreeBSD"), | ||
(OS::FreeBSD, Arch::Universal2) => bail!("universal2 is not supported for FreeBSD"), | ||
(OS::FreeBSD, Arch::X86) => bail!("32-bit wheels are not supported for FreeBSD"), | ||
(OS::FreeBSD, Arch::X86_64) => { | ||
match PlatformInfo::new() { | ||
|
@@ -137,6 +146,7 @@ impl Target { | |
(OS::Macos, Arch::X86) => bail!("32-bit wheels are not supported for macOS"), | ||
(OS::Windows, Arch::AARCH64) => bail!("aarch64 is not supported for Windows"), | ||
(OS::Windows, Arch::ARMV7L) => bail!("armv7l is not supported for Windows"), | ||
(OS::Windows, Arch::Universal2) => bail!("universal2 is not supported for Windows"), | ||
(_, _) => {} | ||
} | ||
Ok(Target { os, arch }) | ||
|
@@ -149,6 +159,7 @@ impl Target { | |
Arch::ARMV7L => 32, | ||
Arch::POWERPC64 => 64, | ||
Arch::POWERPC64LE => 64, | ||
Arch::Universal2 => 64, | ||
Arch::X86 => 32, | ||
Arch::X86_64 => 64, | ||
} | ||
|
@@ -174,6 +185,11 @@ impl Target { | |
self.os == OS::Macos | ||
} | ||
|
||
/// Returns true if the current platform is mac os and arch is universal2 | ||
pub fn is_macos_universal2(&self) -> bool { | ||
self.os == OS::Macos && self.arch == Arch::Universal2 | ||
} | ||
|
||
/// Returns true if the current platform is windows | ||
pub fn is_windows(&self) -> bool { | ||
self.os == OS::Windows | ||
|
@@ -193,6 +209,7 @@ impl Target { | |
(OS::Linux, _) => format!("{}_{}", manylinux, self.arch), | ||
(OS::Macos, Arch::X86_64) => "macosx_10_7_x86_64".to_string(), | ||
(OS::Macos, Arch::AARCH64) => "macosx_11_0_arm64".to_string(), | ||
(OS::Macos, Arch::Universal2) => "macosx_10_9_universal2".to_string(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requires pypa/packaging#380 |
||
(OS::Windows, Arch::X86) => "win32".to_string(), | ||
(OS::Windows, Arch::X86_64) => "win_amd64".to_string(), | ||
(_, _) => panic!("unsupported target should not have reached get_platform_tag()"), | ||
|
@@ -204,7 +221,7 @@ impl Target { | |
vec![format!("py3-none-{}", self.get_platform_tag(&manylinux))] | ||
} | ||
|
||
/// Returns the platform for the tag in the shared libaries file name | ||
/// Returns the platform for the tag in the shared libraries file name | ||
pub fn get_shared_platform_tag(&self) -> &'static str { | ||
match (&self.os, &self.arch) { | ||
(OS::FreeBSD, _) => "", // according imp.get_suffixes(), there are no such | ||
|
@@ -216,8 +233,12 @@ impl Target { | |
(OS::Linux, Arch::X86_64) => "x86_64-linux-gnu", | ||
(OS::Macos, Arch::X86_64) => "darwin", | ||
(OS::Macos, Arch::AARCH64) => "darwin", | ||
(OS::Macos, Arch::Universal2) => "darwin", | ||
(OS::Windows, Arch::X86) => "win32", | ||
(OS::Windows, Arch::X86_64) => "win_amd64", | ||
(OS::Linux, _) => { | ||
panic!("unsupported Linux Arch should not have reached get_shared_platform_tag()") | ||
} | ||
(OS::Macos, _) => { | ||
panic!("unsupported macOS Arch should not have reached get_shared_platform_tag()") | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently Cargo does have builtin support creating macOS Universal/fat binaries: rust-lang/cargo#8875