{"record":{"id":"2c80f7fbde669685","repo":"sgl-project/sglang","slug":"setup-metal-py-only-supports-macos-apple-silicon","errorCode":null,"errorMessage":"setup_metal.py only supports macOS (Apple Silicon).","messagePattern":"setup_metal\\.py only supports macOS \\(Apple Silicon\\)\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/aot/setup_metal.py","lineNumber":37,"sourceCode":"import shutil\nimport subprocess\nimport sys\nimport sysconfig\nfrom pathlib import Path\n\nroot = Path(__file__).parent.resolve()\n\n\n_BUILD_REQUIRES = [\n    (\"setuptools\", \"setuptools\"),\n    (\"mlx\", \"mlx\"),\n    (\"nanobind\", \"nanobind\"),\n]\n\n\ndef _ensure_toolchain():\n    if sys.platform != \"darwin\" or platform.machine() != \"arm64\":\n        raise SystemExit(\"setup_metal.py only supports macOS (Apple Silicon).\")\n    if shutil.which(\"c++\") is None or shutil.which(\"xcrun\") is None:\n        raise SystemExit(\n            \"Apple toolchain not found. Install the Xcode Command Line Tools \"\n            \"with `xcode-select --install` (or a full Xcode install) and retry.\"\n        )\n    try:\n        subprocess.check_output(\n            [\"xcrun\", \"-sdk\", \"macosx\", \"metal\", \"--version\"],\n            stderr=subprocess.STDOUT,\n        )\n    except (subprocess.CalledProcessError, FileNotFoundError) as exc:\n        raise SystemExit(\n            \"Apple Metal shader compiler not found. Install a full Xcode \"\n            \"(not just Command Line Tools) so that `xcrun -sdk macosx metal` \"\n            \"is available, then retry.\"\n        ) from exc\n\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/aot/setup_metal.py#L19-L55","documentation":"The Metal extension build script refuses to run anywhere other than macOS on Apple Silicon (darwin/arm64). Building the Metal/MLX kernels requires the Apple toolchain, so Linux/Intel platforms exit immediately.","triggerScenarios":"Running `python setup_metal.py ...` (or pip installing the aot package in a way that invokes it) on Linux, in an x86_64 Mac container/CI, or under Rosetta where platform.machine() reports x86_64.","commonSituations":"Shared CI pipelines that build all kernel variants on Linux runners; developers on Intel Macs; Docker containers with Linux images attempting to build the metal extra.","solutions":["Skip/gate the Metal build on non-darwin-arm64 (check sys.platform and platform.machine() in your build script)","Run this build only on an Apple-Silicon macOS runner/machine","Ensure native arm64 Python is used (not Rosetta/x86_64) if you are on an M-series Mac"],"exampleFix":"# before\npython setup_metal.py build_ext --inplace  # on Linux CI\n# after\nimport sys, platform\nif sys.platform == 'darwin' and platform.machine() == 'arm64':\n    subprocess.run(['python', 'setup_metal.py', 'build_ext', '--inplace'])","handlingStrategy":"validation","validationCode":"import sys, platform\nassert sys.platform=='darwin' and platform.machine()=='arm64'","typeGuard":"def on_apple_silicon(): return sys.platform=='darwin' and platform.machine()=='arm64'","tryCatchPattern":null,"preventionTips":["Gate metal builds in CI matrices by platform"],"tags":["metal","build","platform-check","apple-silicon"],"backgroundTag":"unsupported-platform-build","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}