Detect x86_64 Python under Rosetta on Apple Silicon (sqlite-vec 'Illegal instruction' crash)
On an Apple Silicon Mac, an Intel (x86_64) Python build, e.g. some Miniconda installs, runs under Rosetta. Loading native SQLite extensions such as sqlite_vec.load(conn) can hard-crash the interpreter with Fatal Python error: Illegal instruction, so no Python exception or friendly error message is ever shown.
Detect it before loading the extension, without shelling out to sysctl:
import os, platform, sys
def running_under_rosetta() -> bool:
return (sys.platform == "darwin"
and platform.machine() == "x86_64"
and "ARM64" in os.uname().version)Under Rosetta, platform.machine() reports x86_64 but the kernel version string still contains RELEASE_ARM64_.... Log a warning, or refuse to load, and tell the user to use a native arm64 Python (python.org or Homebrew); python -c "import platform; print(platform.machine())" should print arm64. A separate issue: a Python built without enable_load_extension raises a normal AttributeError, which you can catch.