Skip to content

Commit 97cd9da

Browse files
committed
Fix arch detection
1 parent 720092f commit 97cd9da

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/python/stubs/generate_stubs_local.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ def main():
2424
if platform.system() == "Darwin":
2525
# On Mac, `uname -m`, $CMAKE_HOST_SYSTEM_PROCESSOR, and platform.machine() returns
2626
# x86_64 even on arm64 processors (i.e. Apple Silicon) if cmake or python is running under
27-
# emulation (Rosetta).
28-
arch = subprocess.check_output(["sysctl", "-n", "hw.machine"], text=True).strip()
27+
# emulation (Rosetta). sysctl.proc_translated tells us if we're under emulation.
28+
arch = subprocess.check_output(["uname", "-m"], text=True).strip()
29+
if arch == "x86_64":
30+
process_uses_emulation = subprocess.check_output(
31+
["sysctl", "-in", "sysctl.proc_translated"], text=True
32+
).strip()
33+
if process_uses_emulation == "1":
34+
arch = "arm64"
2935
else:
3036
arch = platform.machine()
3137
if arch == "arm64":

0 commit comments

Comments
 (0)