PybindCompiler#

class scikitplot.cython.PybindCompiler[source]#

Built-in custom compiler for Scenario 4: pybind11-only projects.

This compiler wraps the standard Cython+setuptools pipeline but automatically injects the pybind11 include directory and sets language="c++".

Attributes:
namestr

Always "custom_pybind11".

Notes

Master user note: register and use this compiler when building pybind11 extension modules without Cython .pyx files. You write standard C++ with pybind11 macros; this compiler handles the rest:

from scikitplot.cython._custom_compiler import PybindCompiler, register_compiler

register_compiler(PybindCompiler())

The compiler requires pybind11 to be importable. Check with pybind11_only_prereqs.

Examples

>>> pc = PybindCompiler()
>>> pc.name
'custom_pybind11'
>>> isinstance(pc, CustomCompilerProtocol)
True
__call__(source, *, build_dir, module_name, include_dirs=None, extra_compile_args=None, extra_link_args=None, **kwargs)[source]#

Compile a pybind11 C++ extension from source text.

Parameters:
sourcestr

C++ source code with pybind11 bindings.

build_dirpathlib.Path

Output directory.

module_namestr

Python module name for the compiled extension.

include_dirssequence of path-like or None

Additional include directories (pybind11 headers added automatically).

extra_compile_argssequence of str or None

Additional C++ compiler flags (-std=c++17 added by default).

extra_link_argssequence of str or None

Additional linker flags.

**kwargs

Ignored extra arguments for forward compatibility.

Returns:
pathlib.Path

Path to the compiled .so / .pyd artifact.

Raises:
ImportError

If pybind11 is not installed.

RuntimeError

If compilation fails.

Parameters:
Return type:

Path

name: str = 'custom_pybind11'#