CustomCompilerProtocol#

class scikitplot.cython.CustomCompilerProtocol(*args, **kwargs)[source]#

Structural protocol for custom compiler callables.

Any callable that satisfies this protocol can be registered with CompilerRegistry and 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_ or Custom. 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-set frozen dataclass 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())
__call__(source, *, build_dir, module_name, **kwargs)[source]#

Compile source and return the artifact path.

Parameters:
Return type:

Path

name: str#