sgl-project/sglang · error · RuntimeError
Python did not report an EXT_SUFFIX for native extensions
Error message
Python did not report an EXT_SUFFIX for native extensions
What it means
sysconfig.get_config_var('EXT_SUFFIX') returned empty, so the loader cannot name the cached native extension file. Indicates a broken/unusual Python build.
Source
Thrown at python/sglang/srt/rust_extensions/loader.py:308
serialized = json.dumps(
value, sort_keys=True, separators=(",", ":"), ensure_ascii=True
).encode()
return hashlib.sha256(serialized).hexdigest()
def _cache_root(cache_dir: Path | None) -> Path:
if cache_dir is not None:
return Path(cache_dir).expanduser().resolve()
sglang_cache = envs.SGLANG_CACHE_DIR.get()
return Path(sglang_cache).expanduser().resolve() / "rust_extensions"
def _cached_extension_path(
cache_root: Path, crate: _CrateSpec, fingerprint: str
) -> Path:
extension_suffix = sysconfig.get_config_var("EXT_SUFFIX")
if not extension_suffix:
raise RuntimeError("Python did not report an EXT_SUFFIX for native extensions")
module_leaf = crate.python_module.rsplit(".", 1)[-1]
return (
cache_root
/ "artifacts"
/ crate.package
/ fingerprint
/ (module_leaf + extension_suffix)
)
@contextmanager
def _filesystem_lock(path: Path) -> Iterator[None]:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("a+b") as lock_file:
fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX)
try:
yield
finally:View on GitHub (pinned to 0132848349)
Solutions
- Use a standard CPython build
- Set/repair the interpreter's sysconfig vars or pass a working sys.executable
- Run `python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"` to confirm the environment is broken
Defensive patterns
Strategy: validation
Validate before calling
import sysconfig
assert sysconfig.get_config_var("EXT_SUFFIX"), "unsupported Python build" Prevention
- Use standard CPython distributions
- Sanity-check sysconfig vars when targeting exotic runtimes
When it happens
Trigger: load_rust_extension on a Python interpreter built without extension suffix configuration (some embedded, stripped, or exotic builds).
Common situations: Embedded Python distributions, custom minimal Pythons, or sysconfig data missing; rarely on normal CPython installs.
Related errors
- Can not import FA3 in sgl_kernel. Please check your installa
- could not create an import spec for {module_name} at {path}
- module {__name__!r} has no attribute {name!r}
- op {op!r} has no backend usable on device {platform.device.v
- GenerativeModel
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b087c158daf1fc17.
Report an issue: GitHub.