From d924beffe5ae2dcc6c981f4fea10dc1d00233f50 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 24 Oct 2026 13:06:00 +0200 Subject: [PATCH] setup: a Mac with an Intel (Rosetta) Python is still an Apple Silicon Mac; the chip name and hw.optional.arm64 decide, one plain line says the Python is an Intel build (#3894); test --- setup.py | 3 +++ strata_control/mac_fit.py | 6 +++++- tools/test_setup_mac.py | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f3689cac..d65c1608 100644 --- a/setup.py +++ b/setup.py @@ -8249,6 +8249,9 @@ def mac_control_setup(a) -> int: info = MF.mac_info() ram = float(info["ram_gb"] or ram_gb()) ok(f"{info['chip']}, {ram:.0f} GB unified memory, macOS {info['macos'] or '?'}") + if info.get("rosetta_python"): + say(" (the Python that runs this is an Intel build running through Rosetta: Strata works, and the Apple Silicon Python " + "from python.org or Homebrew in /opt/homebrew is a little faster to start)") problems = MF.mac_problems(info, need_compiler=False) # the app compiles nothing: no Command Line Tools needed for p in problems: warn(p) diff --git a/strata_control/mac_fit.py b/strata_control/mac_fit.py index 68a7b106..a273c741 100644 --- a/strata_control/mac_fit.py +++ b/strata_control/mac_fit.py @@ -94,7 +94,11 @@ def mac_info(run=subprocess.run) -> dict: clt_path = clt.stdout.strip() if clt.returncode == 0 else "" except (OSError, subprocess.SubprocessError): clt_path = "" - return {"chip": chip, "ram_gb": ram, "macos": ver, "arm64": platform.machine() == "arm64", + # platform.machine() is the PYTHON's build: an Intel Python running through Rosetta says x86_64 on an M1 Max (#3894). The chip name + # (Rosetta passes "Apple M1 Max" through) and hw.optional.arm64 say what the Mac is. + python_arm = platform.machine() == "arm64" + mac_arm = python_arm or _sysctl("hw.optional.arm64", run) == "1" or chip.startswith("Apple") + return {"chip": chip, "ram_gb": ram, "macos": ver, "arm64": mac_arm, "rosetta_python": mac_arm and not python_arm, "clt": clt_path, "perf_cores": int(_sysctl("hw.perflevel0.physicalcpu", run) or 0)} diff --git a/tools/test_setup_mac.py b/tools/test_setup_mac.py index fd0b5a95..92f2a596 100644 --- a/tools/test_setup_mac.py +++ b/tools/test_setup_mac.py @@ -49,6 +49,13 @@ class MacCheck(unittest.TestCase): self.assertTrue(info["clt"]) self.assertEqual(M.mac_problems(info), []) + def test_an_intel_python_on_apple_silicon_is_still_an_apple_silicon_mac(self): # #3894 + with mock.patch.object(M.platform, "machine", return_value="x86_64"): + info = M.mac_info(fake_run({**M5, "machdep.cpu.brand_string": "Apple M1 Max"})) + self.assertTrue(info["arm64"]) + self.assertTrue(info["rosetta_python"]) + self.assertNotIn("Intel", " ".join(M.mac_problems(info))) + def test_intel_old_macos_and_missing_tools_are_named(self): with mock.patch.object(M.platform, "machine", return_value="x86_64"): info = M.mac_info(fake_run({**M5, "macos": "14.6", "machdep.cpu.brand_string": "Intel Core i9"}, clt_rc=2))