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
The loader asked the running Python interpreter for sysconfig EXT_SUFFIX (the platform's native extension suffix such as .cpython-311-x86_64-linux-gnu.so) and got an empty/unset value. Without it the built Rust artifact cannot be named correctly for import.
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…
- could not create an import spec for
- cannot force-build after it has been imported; start a new…
- cuda.bindings.driver is required for CUDA VMM operations
- Either quant_config or online_scheme must be provided
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b087c158daf1fc17.
Report an issue: GitHub.
Appendix: 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)