scikit_build_core.settings package¶
Submodules¶
scikit_build_core.settings.auto_cmake_version module¶
scikit_build_core.settings.auto_requires module¶
scikit_build_core.settings.documentation module¶
scikit_build_core.settings.json_schema module¶
scikit_build_core.settings.skbuild_docs_readme module¶
scikit_build_core.settings.skbuild_docs_sphinx module¶
Make documentation for the skbuild model in sphinx format.
scikit_build_core.settings.skbuild_model module¶
- class scikit_build_core.settings.skbuild_model.BackportSettings(find_python=<Version('3.26.1')>)[source]¶
Bases:
object
- class scikit_build_core.settings.skbuild_model.BuildSettings(tool_args=<factory>, targets=<factory>, verbose=False, requires=<factory>)[source]¶
Bases:
object- requires: List[str]¶
Additional
build-system.requires.Intended to be used in combination with
overrides.
- class scikit_build_core.settings.skbuild_model.CMakeSettings(minimum_version=None, version=None, args=<factory>, define=<factory>, verbose=None, build_type='Release', source_dir=PosixPath('.'), targets=None, toolchain_file=None, python_hints=True)[source]¶
Bases:
object- args: List[str]¶
A list of args to pass to CMake when configuring the project.
Setting this in config or envvar will override toml.
See also
- build_type: str = 'Release'¶
The build type to use when building the project.
Pre-defined CMake options are:
Debug,Release,RelWithDebInfo,MinSizeRelCustom values can also be used.
- define: Annotated[Dict[str, CMakeSettingsDefine], 'EnvVar']¶
A table of defines to pass to CMake when configuring the project. Additive.
- python_hints: bool = True¶
Do not pass the current environment’s python hints such as
Python_EXECUTABLE. Primarily used for cross-compilation where the CMAKE_TOOLCHAIN_FILE should handle it instead.
- source_dir: Path = PosixPath('.')¶
The source directory to use when building the project.
Currently only affects the native builder (not the setuptools plugin).
- toolchain_file: Path | None = None¶
The CMAKE_TOOLCHAIN_FILE / –toolchain used for cross-compilation.
This is only allowed in overrides or config-settings.
- version: SpecifierSet | None = None¶
The versions of CMake to allow as a python-compatible specifier.
If CMake is not present on the system or does not pass this specifier, it will be downloaded via PyPI if possible with the equivalent specifier used.
An empty string will disable this check.
- Special cases:
On scikit-build-core 0.10+
CMakeLists.txtis the default value otherwise it’s>=3.15.If
CMakeLists.txtis passed, thecmake_minimum_requiredis read from the CMakeLists.txt file, using that as the minimum specifier. If the file fails to read,>=3.15is used instead.
See also
- class scikit_build_core.settings.skbuild_model.CMakeSettingsDefine(raw: str | bool | List[str])[source]¶
Bases:
strA str subtype for automatically normalizing bool and list values to the CMake representation in the cmake.define settings key.
- json_schema = str | bool | typing.List[str]¶
- class scikit_build_core.settings.skbuild_model.EditableSettings(mode='redirect', verbose=True, rebuild=False)[source]¶
Bases:
object
- class scikit_build_core.settings.skbuild_model.GenerateSettings(path, template='', template_path=None, location='install')[source]¶
Bases:
object- location: Literal['install', 'build', 'source'] = 'install'¶
The place to put the generated file.
The
builddirectory is useful for CMake files, and theinstalldirectory is useful for Python files, usually. You can also write directly to thesourcedirectory, will overwrite existing files & remember to gitignore the file.
- template: str = ''¶
The template string to use for the file.
Template style placeholders are available for all the metadata.
Either this or
generate[].template-pathmust be set.See also
- template_path: Path | None = None¶
The path to the template file. If empty, a template must be set.
Either this or
generate[].templatemust be set.See also
- class scikit_build_core.settings.skbuild_model.InstallSettings(components=<factory>, strip=None)[source]¶
Bases:
object
- class scikit_build_core.settings.skbuild_model.LoggingSettings(level='WARNING')[source]¶
Bases:
object
- class scikit_build_core.settings.skbuild_model.MessagesSettings(after_failure='', after_success='')[source]¶
Bases:
objectSettings for messages.
- class scikit_build_core.settings.skbuild_model.NinjaSettings(minimum_version=None, version=<SpecifierSet('>=1.5')>, make_fallback=True)[source]¶
Bases:
object- make_fallback: bool = True¶
Use Make as a fallback if a suitable Ninja executable is not found.
If Make is also not available on the system, a ninja dependency is added to the
build-system.requiresaccording toninja.version.See also
- version: SpecifierSet = <SpecifierSet('>=1.5')>¶
The versions of Ninja to allow.
If Ninja is not present on the system or does not pass this specifier, it will be downloaded via PyPI if possible with the equivalent specifier used.
An empty string will disable this check.
See also
- class scikit_build_core.settings.skbuild_model.SDistSettings(include=<factory>, exclude=<factory>, inclusion_mode=None, reproducible=True, cmake=False)[source]¶
Bases:
object- exclude: List[str]¶
Files to exclude from the SDist even if they are included by default. Supports gitignore syntax.
See also
- include: List[str]¶
Files to include in the SDist even if they are skipped by default. Supports gitignore syntax.
Always takes precedence over
sdist.excludeSee also
- inclusion_mode: Literal['classic', 'default', 'manual'] | None = None¶
Method to use to compute the files to include and exclude.
The methods are:
“default”: Process the git ignore files. Shortcuts on ignored directories.
“classic”: The behavior before 0.12, like “default” but does not shortcut directories.
“manual”: No extra logic, based on include/exclude only.
If you don’t set this, it will be “default” unless you set the minimum version below 0.12, in which case it will be “classic”.
- class scikit_build_core.settings.skbuild_model.ScikitBuildSettings(cmake=<factory>, ninja=<factory>, logging=<factory>, sdist=<factory>, wheel=<factory>, backport=<factory>, editable=<factory>, build=<factory>, install=<factory>, generate=<factory>, messages=<factory>, search=<factory>, metadata=<factory>, strict_config=True, experimental=False, minimum_version=None, build_dir='', fail=None)[source]¶
Bases:
object- backport: BackportSettings¶
- build: BuildSettings¶
- build_dir: str = ''¶
The CMake build directory. Defaults to a unique temporary directory.
This can be set to reuse the build directory from previous runs.
- cmake: CMakeSettings¶
- editable: EditableSettings¶
- fail: bool | None = None¶
Immediately fail the build. This is only allowed in overrides or config-settings.
- generate: List[GenerateSettings]¶
- install: InstallSettings¶
- logging: LoggingSettings¶
- messages: MessagesSettings¶
- minimum_version: Version | None = None¶
If set, this will provide a method for backward compatibility.
- ninja: NinjaSettings¶
- sdist: SDistSettings¶
- search: SearchSettings¶
- strict_config: bool = True¶
Strictly check all config options.
If False, warnings will be printed for unknown options.
If True, an error will be raised.
- wheel: WheelSettings¶
- class scikit_build_core.settings.skbuild_model.SearchSettings(site_packages=True)[source]¶
Bases:
object
- class scikit_build_core.settings.skbuild_model.WheelSettings(packages=None, py_api='', expand_macos_universal_tags=False, install_dir='', license_files=None, cmake=True, platlib=None, exclude=<factory>, build_tag='', tags=None)[source]¶
Bases:
object- exclude: List[str]¶
A set of patterns to exclude from the wheel.
This is additive to the SDist exclude patterns. This applies to the final paths in the wheel, and can exclude files from CMake output as well. Editable installs may not respect this exclusion.
- expand_macos_universal_tags: bool = False¶
Fill out extra tags that are not required.
This adds “x86_64” and “arm64” to the list of platforms when “universal2” is used, which helps older Pip’s (before 21.0.1) find the correct wheel.
- install_dir: str = ''¶
The CMake install prefix relative to the platlib wheel path.
You might set this to the package name to install everything under the package namespace in a pythonic design.
The original dir is still at
SKBUILD_PLATLIB_DIR(alsoSKBUILD_DATA_DIR, etc. are available).Warning
EXPERIMENTAL An absolute path will be one level higher than the platlib root, giving access to “/platlib”, “/data”, “/headers”, and “/scripts”.
- license_files: List[str] | None = None¶
A list of license files to include in the wheel. Supports glob patterns.
The default is
["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"].Warning
Must not be set if
project.license-filesis set.
- packages: List[str] | Dict[str, str] | None = None¶
A list of packages to auto-copy into the wheel.
If this is not set, it will default to the first of
src/<package>,python/<package>, or<package>if they exist. The prefix(s) will be stripped from the package name inside the wheel.If a dict, provides a mapping of package name to source directory.
- platlib: bool | None = None¶
Target the platlib or the purelib.
If not set, the default is to target the platlib if
wheel.cmakeistrue, and the purelib otherwise.
- py_api: str = ''¶
The Python version tag used in the wheel file.
The default (empty string) will use the default Python version.
You can also set this to “cp38” to enable the CPython 3.8+ Stable ABI / Limited API (only on CPython and if the version is sufficient, otherwise this has no effect). For free-threaded Python, you can use “cp315t” to enable the free-threaded stable ABI (only on CPython free-threaded builds and if the version is sufficient). Or you can set it to “py3” or “py2.py3” to ignore Python ABI compatibility. The ABI tag is inferred from this tag.
This value is used to construct
SKBUILD_SABI_COMPONENTCMake variable.
- tags: List[str] | None = None¶
Wheel tags to manually force, {interpreter}-{abi}-{platform} format.
Manually specify the wheel tags to use, ignoring other inputs such as
wheel.py-api. Each tag must be of the format {interpreter}-{abi}-{platform}. If not specified, these tags are automatically calculated. This is only allowed in overrides or config-settings.
scikit_build_core.settings.skbuild_overrides module¶
- class scikit_build_core.settings.skbuild_overrides.OverrideRecord(key, original_value, value, passed_all, passed_any)[source]¶
Bases:
objectRecord of the override action.
Saves the original and final values, and the override reasons.
scikit_build_core.settings.skbuild_read_settings module¶
- class scikit_build_core.settings.skbuild_read_settings.SettingsReader(pyproject, config_settings, *, state, extra_settings=None, verify_conf=True, env=None, retry=False)[source]¶
Bases:
object
scikit_build_core.settings.skbuild_schema module¶
scikit_build_core.settings.sources module¶
This module implements the configuration sources used by scikit-build-core.
Each concrete Source adapts one input representation, such as
environment variables, PEP 517 config-settings, or nested TOML tables, into
the same nested dataclass model. SourceChain combines those sources and
applies them in precedence order when building the final settings object.
An end user usually interacts with SourceChain, which takes a
dataclass type and returns an instance with fields populated.
Example:
@dataclasses.dataclass
class ExampleSettings:
generator: str = "Unix Makefiles"
tags: list[str] = dataclasses.field(default_factory=list)
defines: dict[str, str] = dataclasses.field(default_factory=dict)
pyproject = {
"tool": {
"example": {
"generator": "Unix Makefiles",
"defines": {"A": "1"},
}
}
}
env = {"EXAMPLE_TAGS": "fast;docs", "EXAMPLE_DEFINES": "B=2"}
config_settings = {"generator": "Ninja"}
sources = SourceChain(
EnvSource("EXAMPLE", env=env),
ConfSource(settings=config_settings),
TOMLSource("tool", "example", settings=pyproject),
)
settings = sources.convert_target(ExampleSettings)
assert settings.generator == "Ninja"
assert settings.tags == ["fast", "docs"]
assert settings.defines == {"B": "2", "A": "1"}
unrecognized_options = list(sources.unrecognized_options(ExampleSettings))
Naming conventions:
modelis the complete Dataclass.targetis the type to convert a single item to.settingsis the input data source (unless it already has a name, likeenv).optionsare the names of the items in themodel, formatted in the style of the current Source.fieldsare the tuple of strings describing a nested field in themodel.
Source representations:
EnvSource: reads values in environment variables. Lists are encoded as"a;b"and dicts as"key=value;other=value".ConfSource: reads values in a flat mapping keyed by dotted option names from the command line, like-Ca.b=c.TOMLSource: reads values in a nested TOML mapping, like inpyproject.toml.SourceChain: queries sources in order and asks the first matching source to convert its native value into the requested dataclass field type.
When setting up your dataclasses, these types are handled:
str: A string type, nothing special.bool: Supports bool in TOML, not handled in envvar/config (so only useful in a Union)Any callable (Path, Version): Passed the string input.
Optional[T]: Treated like T. Default should be None, since no input format supports None’s.Union[str, ...]: Supports other input types in TOML form (bool currently). Otherwise a string.List[T]: A list of items. ; separated supported in EnvVar/config forms. T can be a dataclass (TOML only).Dict[str, T]: A table of items. TOML supports a layer of nesting. Any is supported as an item type.Union[list[T], Dict[str, T]](TOML only): A list or dict of items.Literal[...]: A list of strings, the result must be in the list.Annotated[Dict[...], "EnvVar"]: A dict of items, where each item can be a string or a dict with “env” and “default” keys.
These are supported for JSON schema generation for the TOML, as well.
Integers/floats would be easy to add, but haven’t been needed yet.
- class scikit_build_core.settings.sources.ConfSource(*prefixes, settings, verify=True)[source]¶
Bases:
SourceSource for PEP 517
config-settings.While most mechanisms (pip, uv, build) only support text, gpep517 allows an arbitrary json input, so this currently also handles bools.
Example:
source = ConfSource( "skbuild", settings={ "skbuild.logging.level": "DEBUG", "skbuild.cmake.define.CMAKE_CXX_STANDARD": "20", }, ) assert source.get_item("logging", "level", is_dict=False) == "DEBUG" assert source.get_item("cmake", "define", is_dict=True) == { "CMAKE_CXX_STANDARD": "20" }
- all_option_names(target)[source]¶
Given a model, produce a list of all possible names (used for producing suggestions).
- classmethod convert(item, target)[source]¶
Convert a source-native
iteminto the requestedtargettype.Raises
TypeErrorif the conversion fails.- Return type:
- get_item(*fields, is_dict)[source]¶
Return the source-native value for a field path.
The return type depends on the source: env returns a raw string, config-settings returns a string/list/bool or reconstructed dict, and TOML returns the native TOML object. Raises
KeyErrorif the value is missing.is_dictis set for dict-typed targets, because some sources represent dict entries as nested keys.
- has_item(*fields, is_dict)[source]¶
Check whether the source contains a field path.
For example,
fields=("a", "b")asks whether the source has a value for the nested model fielda.b.is_dictis set for dict-typed targets, because some sources represent dict entries as nested keys.- Return type:
- settings: Mapping[str, str | list[str] | bool]¶
Flat backend
config-settingsmapping keyed by dotted option names.Scalar values are stored directly. Dict-typed target fields are represented by multiple flat entries such as
"sdist.include.foo" = "bar".
- class scikit_build_core.settings.sources.EnvSource(prefix, *, env=None)[source]¶
Bases:
SourceSource backed by environment variables.
Nested field paths are represented by uppercased underscore-separated names such as
PREFIX_A_B. Values remain raw strings in the environment until they are converted into the requested field type.Example:
env = { "SKBUILD_CMAKE_ARGS": "-GNinja;-DCMAKE_BUILD_TYPE=Debug", "SKBUILD_CMAKE_DEFINE": "CMAKE_CXX_STANDARD=20;BUILD_TESTING=OFF", } source = EnvSource("SKBUILD", env=env) assert source.get_item("cmake", "args", is_dict=False) == ( "-GNinja;-DCMAKE_BUILD_TYPE=Debug" ) assert source.get_item("cmake", "define", is_dict=False) == ( "CMAKE_CXX_STANDARD=20;BUILD_TESTING=OFF" )
- all_option_names(target)[source]¶
Given a model, produce a list of all possible names (used for producing suggestions).
- classmethod convert(item, target)[source]¶
Convert an item from the environment (always a string) into a target type.
- Return type:
- get_item(*fields, is_dict)[source]¶
Return the source-native value for a field path.
The return type depends on the source: env returns a raw string, config-settings returns a string/list/bool or reconstructed dict, and TOML returns the native TOML object. Raises
KeyErrorif the value is missing.is_dictis set for dict-typed targets, because some sources represent dict entries as nested keys.
- class scikit_build_core.settings.sources.Source(*args, **kwargs)[source]¶
Bases:
Protocol- all_option_names(target)[source]¶
Given a model, produce a list of all possible names (used for producing suggestions).
- classmethod convert(item, target)[source]¶
Convert a source-native
iteminto the requestedtargettype.Raises
TypeErrorif the conversion fails.- Return type:
- get_item(*fields, is_dict)[source]¶
Return the source-native value for a field path.
The return type depends on the source: env returns a raw string, config-settings returns a string/list/bool or reconstructed dict, and TOML returns the native TOML object. Raises
KeyErrorif the value is missing.is_dictis set for dict-typed targets, because some sources represent dict entries as nested keys.- Return type:
- class scikit_build_core.settings.sources.SourceChain(*sources, prefixes=())[source]¶
Bases:
object- convert_target(target, *prefixes)[source]¶
Build a dataclass instance from the chained sources.
For each field, this first asks each source whether it has a native value for the current path. The first matching source returns that raw value via
get_item, and that same source then normalizes it withconvertinto the dataclass field type. Nested dataclasses recurse intoconvert_target. Dict fields are special: later sources extend the dict assembled so far instead of replacing it outright.Example:
@dataclasses.dataclass class Example: tags: list[str] = dataclasses.field(default_factory=list) defines: dict[str, str] = dataclasses.field(default_factory=dict) chain = SourceChain( EnvSource("EXAMPLE", env={"EXAMPLE_DEFINES": "A=1"}), ConfSource(settings={"tags": ["from-conf"]}), TOMLSource(settings={"tags": ["from-toml"], "defines": {"B": "2"}}), ) settings = chain.convert_target(Example) assert settings.tags == ["from-conf"] assert settings.defines == {"A": "1", "B": "2"}
- Return type:
TypeVar(T)
- class scikit_build_core.settings.sources.TOMLSource(*prefixes, settings)[source]¶
Bases:
SourceSource backed by a nested TOML mapping.
After applying any constructor prefixes,
self.settingsis the nested table for that subtree.get_itemreturns the native TOML value found at the requested field path, andconvertturns that TOML value into the target dataclass field type.Example:
source = TOMLSource( "tool", "scikit-build", settings={ "tool": { "scikit-build": { "wheel": {"packages": ["src/example"]}, } } }, ) assert source.get_item("wheel", "packages", is_dict=False) == ["src/example"]
- all_option_names(target)[source]¶
Given a model, produce a list of all possible names (used for producing suggestions).
- classmethod convert(item, target)[source]¶
Convert an
itemfrom TOML into atargettype.- Return type:
- get_item(*fields, is_dict)[source]¶
Return the source-native value for a field path.
The return type depends on the source: env returns a raw string, config-settings returns a string/list/bool or reconstructed dict, and TOML returns the native TOML object. Raises
KeyErrorif the value is missing.is_dictis set for dict-typed targets, because some sources represent dict entries as nested keys.- Return type: