Reference¶
This page lists every configuration option, with its type and default. Options fall into two kinds:
Common options may be set at the package, module, or class level and inherit downwards: a value set on the package applies to every module and class in it, unless a lower level overrides it. For example,
auto_includesset at the package level applies to the whole package.Level-specific options are only meaningful at one level. For example:
modulesat the package level.importsat the module level.name_overrideat the class level.
Each table below covers one level; a – in the Default column marks a
required option.
Common options¶
Settable at the package, module, or class level; they inherit downwards.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
list[str] |
|
Skip any method/constructor with an argument type matching one of these. |
|
bool |
|
Auto-resolve headers for project types used in wrapped signatures. See Includes. |
|
list[str] |
|
Skip any constructor with an argument type matching one of these. |
|
list[list[str]] |
|
Skip a constructor whose full argument-type list matches an entry. |
|
str |
|
Path to a Python template that injects extra binding code. See Custom generators. |
|
dict |
|
Drop discovered instantiations by template-argument value. See Templates. |
|
bool |
|
Auto-discover explicit instantiations from the source. See Templates. |
|
bool |
|
Exclude the whole class from wrapping. |
|
list[str] |
|
Method names to skip. |
|
list[str] |
|
Public data member names to skip (they are otherwise bound with |
|
str |
|
Default pybind11 |
|
list[str] |
|
Lines emitted before a class’s registration block. |
|
str |
|
Text emitted at the top of each wrapper file (e.g. a licence header). |
|
str |
|
Default pybind11 |
|
list[str] |
|
Skip any method with a return type matching one of these. |
|
str |
|
Holder type declared for wrapped classes, e.g. |
|
list[str] |
|
Extra headers to add to the wrapper’s |
|
list[str] |
|
Lines emitted after a class’s |
|
list |
|
Explicit template instantiations to wrap. See Templates. |
CPPWG_SOURCEROOT in a path value (e.g. in custom_generator) is replaced with
the source root directory.
Package options¶
Set at the top level of the file.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
If true, every wrapper includes a single shared header collection instead of its own headers. Turn off so each wrapper includes only what it needs. |
|
list |
|
C++ exception classes to translate into Python. See Exceptions. |
|
bool |
|
If true, omit C++ default argument values from the generated bindings. |
|
bool |
|
If true, skip redundant |
|
list |
– |
The modules to build. See Module options. |
|
str |
|
Package name; prepended to every module’s extension name ( |
|
list[str] |
|
Glob patterns for the source files cppwg scans (used for template-instantiation discovery). |
|
list[str] |
|
Glob patterns for the header files cppwg scans. |
|
list |
|
Type-caster headers to auto-include by type. See Type casters. |
All common options may also be set here.
Module options¶
Each entry under modules:.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
list |
|
Classes to wrap, or the string |
|
list |
|
Plain (namespace-scope) enums to wrap, or |
|
list[str] |
|
Base-class names registered by an imported package, so cppwg will emit them as bases. See Cross-module inheritance. |
|
list |
|
Free functions to wrap, or |
|
list[str] |
|
Python modules to import at the start of this module, so their types are registered first. Required for cross-module inheritance. See Cross-module inheritance. |
|
str |
|
Module name; the extension is |
|
list[str] |
|
Directories (relative to the source root) that scope this module: they bound both the classes wrapped and the |
All common options may also be set here.
Class options¶
Each entry under a module’s classes:.
Two options point cppwg at an entity’s header, and they differ. source_file is
a bare filename (e.g. Rectangle.hpp), resolved via the build’s include
path; source_file_path is a path relative to the source root (e.g.
primitives/Rectangle.hpp) that cppwg resolves to a full path and checks exists.
A class is matched to its header automatically — by its name (Foo ↔ Foo.hpp),
or by source_file when the name differs from the filename — so a class usually
needs neither. Free functions and enums are not matched this way, so each
must point at its header with source_file or source_file_path for it to be
parsed (see the sections below).
Option |
Type |
Default |
Description |
|---|---|---|---|
|
str |
– |
The C++ class name (required). |
|
str |
|
Python name for the class, if different from the C++ name. |
|
str |
|
Filename of the header to attribute the class to, when the class name does not match its file name. Emitted as the class’s |
|
str |
|
Path (relative to the source root) to the class’s header, resolved and verified — an explicit alternative to the automatic name/ |
All common options may also be set here.
Note
A plain struct is wrapped here under classes, exactly like a class (its
members are public by default). Public data members are exposed with
pybind11’s def_readwrite (or def_readonly for a const member); use
excluded_variables to suppress a field. Members that cannot
be bound are skipped automatically: static, bitfield, C-style array (e.g.
double coords[3]) and reference members (none has a takeable
pointer-to-member address), and mutable members whose type is not copy-assignable
(e.g. std::unique_ptr or std::atomic, whose def_readwrite setter would not
compile). (The only special case is a struct wrapping a single nested enum — see
the note under Enum options.)
Free function options¶
Each entry under a module’s free_functions:. Point cppwg at the function’s
header with source_file or source_file_path so it is parsed — required for an
explicitly listed free function (it is not matched to a header the way a class
is), unless the header is already included by a co-located wrapped class.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
str |
– |
The C++ free-function name (required). |
|
str |
|
Filename of the declaring header, resolved via the build’s include path. |
|
str |
|
Path (relative to the source root) to that header, resolved and verified. Takes precedence over |
All common options may also be set here.
Enum options¶
Each entry under a module’s enums:. Point cppwg at the enum’s header with
source_file or source_file_path so it is parsed — required for an explicitly
listed enum, unless the header is already included by a co-located wrapped class.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
str |
– |
The C++ enum name (required). |
|
str |
|
Python name for the enum, if different from the C++ name. |
|
str |
|
Filename of the declaring header, resolved via the build’s include path. |
|
str |
|
Path (relative to the source root) to that header, resolved and verified. Takes precedence over |
|
bool |
unset |
Whether to emit pybind11’s |
All common options may also be set here.
Note
enums is for a plain, namespace-scope enum (enum or enum class). A
struct that wraps a single enum (struct Foo { enum Value {…}; }) is a struct, so
it goes under classes instead — the class writer recognises
the pattern and wraps it as an enum. Listing such a struct under enums fails (it
is not an enum declaration). The struct-wrapper is a legacy form; prefer a plain
enum here. With CPPWG_ALL, each is discovered by its own key — struct-wrappers
via classes, plain enums via enums — with no overlap.