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

This commit is contained in:
Niko1221 committed 2026-10-24 13:06:00 +02:00
1 parent bdaa93edf0
commit d924beffe5
3 files changed
+15 -1

No files matched your search

+3
View File
@@ -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)
+5 -1
View File
@@ -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)}
+7
View File
@@ -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))