Skip to content

Instantly share code, notes, and snippets.

@pudquick
Last active September 28, 2023 16:27
Show Gist options
  • Save pudquick/ca7fa134895f30b070212ea505cab5eb to your computer and use it in GitHub Desktop.
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
# 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