Skip to content

Instantly share code, notes, and snippets.

@pudquick

pudquick/isM1.py

Last active Dec 30, 2020
Embed
What would you like to do?
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