Last active
September 28, 2023 16:27
-
-
Save pudquick/ca7fa134895f30b070212ea505cab5eb to your computer and use it in GitHub Desktop.
Determine if a Mac can run ARM64 code, whether or not the binary is running in Rosetta 2 via pyobjc
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
# https://developer.apple.com/documentation/corefoundation/3684868-cfbundleisarchitectureloadable?language=objc | |
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture?language=occ | |
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture/nsbundleexecutablearchitecturearm64?language=occ | |
from Foundation import NSBundle | |
import objc | |
CF = NSBundle.bundleWithPath_('/System/Library/Frameworks/CoreFoundation.framework') | |
f = [('CFBundleIsArchitectureLoadable', 'BQ')] | |
objc.loadBundleFunctions(CF, globals(), f) | |
NSBundleExecutableArchitectureARM64 = 0x0100000c | |
def is_arm64(): | |
return CFBundleIsArchitectureLoadable(NSBundleExecutableArchitectureARM64) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment