CustomCompilerProtocol#
- class scikitplot.cython.CustomCompilerProtocol(*args, **kwargs)[source]#
Structural protocol for custom compiler callables.
Any callable that satisfies this protocol can be registered with
CompilerRegistryand used as a drop-in replacement or supplement to the default Cython/setuptools compiler.- Returns:
- pathlib.Path
Absolute path to the compiled artifact (
.so/.pyd).
- Raises:
- RuntimeError
On compilation failure.
Notes
Naming rule: register your compiler with a name that starts with
custom_orCustom. The registry enforces this.Stateless is preferred: make
__call__a pure function of its arguments. If state is needed (e.g., caching an include path), store it in constructor-setfrozendataclass fields.Examples
Minimal custom compiler:
from pathlib import Path from scikitplot.cython._custom_compiler import register_compiler class custom_nvcc: name = "custom_nvcc" def __call__( self, source: str, *, build_dir: Path, module_name: str, **kwargs ) -> Path: # ... invoke nvcc here ... return build_dir / f"{module_name}.so" register_compiler(custom_nvcc())