scikit_build_core.builder package

The items in this module are general tools for building wheels, useful by both the build backend and plugins.

Submodules

scikit_build_core.builder.builder module

class scikit_build_core.builder.builder.Builder(settings, config)[source]

Bases: object

build(build_args, *, build_type=None)[source]
Return type:

None

config: CMaker
configure(*, defines, cache_entries=None, name=None, version=None, limited_api=None, configure_args=())[source]
Return type:

None

get_cmake_args()[source]

Get CMake args from the settings and environment.

Return type:

list[str]

get_generator(*args)[source]
Return type:

str | None

install(install_dir, *, build_type=None)[source]

Install to a path.

Warning: if a package hard-codes CMAKE_INSTALL_PREFIX in the install commands, this will not rewrite those; set that variable when configuring for maximum compatibility.

Return type:

None

settings: ScikitBuildSettings
scikit_build_core.builder.builder.archs_to_tags(archs)[source]

Convert a list of architectures to a list of tags (e.g. “universal2”).

Return type:

list[str]

scikit_build_core.builder.builder.get_archs(env, cmake_args=())[source]

Takes macOS platform settings and returns a list of platforms.

Return type:

list[str]

Example (macOS):

ARCHFLAGS=”-arch x86_64” -> [“x86_64”] ARCHFLAGS=”-arch x86_64 -arch arm64” -> [“x86_64”, “arm64”]

Returns an empty list otherwise or if ARCHFLAGS is not set.

scikit_build_core.builder.builder.get_cmake_args_from_settings(settings, env)[source]

Get CMake args from the settings and environment (settings cmake.args plus the filtered CMAKE_ARGS environment variable).

Return type:

list[str]

scikit_build_core.builder.builder.set_environment_from_settings(env, settings)[source]

Apply the tool.scikit-build.env table to env (mutated in place).

Each entry is resolved against env and written back unless it is already set (setdefault semantics), with force = true overriding. Entries that resolve to nothing are skipped.

Return type:

None

scikit_build_core.builder.generator module

scikit_build_core.builder.generator.parse_generator(args)[source]

Extract the generator from a sequence of CMake arguments, handling both the joined -GNinja and the two-token -G Ninja forms. Returns the last generator specified, or None if no -G is present.

Return type:

str | None

scikit_build_core.builder.generator.set_environment_for_gen(generator, cmake, env, ninja_settings, *, env_managed_keys=())[source]

This function modifies the environment as needed to safely set a generator. You should have used CMAKE_GENERATOR already to get the input generator string.

A reasonable default generator is set if the environment does not already have one set; if ninja is present, ninja will be used over make on Unix.

If gen is not None, then that will be the target generator.

Return type:

Mapping[str, str]

scikit_build_core.builder.get_requires module

class scikit_build_core.builder.get_requires.GetRequires(settings=<factory>)[source]

Bases: object

cmake()[source]
Return type:

Generator[str, None, None]

dynamic_metadata()[source]
Return type:

Generator[str, None, None]

classmethod from_config_settings(config_settings, state='sdist')[source]
Return type:

Self

ninja()[source]
Return type:

Generator[str, None, None]

settings: ScikitBuildSettings
variants()[source]
Return type:

Generator[str, None, None]

scikit_build_core.builder.macos module

class scikit_build_core.builder.macos.MacOSVer(major, minor)[source]

Bases: NamedTuple

major: int

Alias for field number 0

minor: int

Alias for field number 1

scikit_build_core.builder.macos.get_cmake_osx_deployment_target(cmake_defines=None, cmake_args=())[source]

Find an explicit CMAKE_OSX_DEPLOYMENT_TARGET known before the build directory exists: a cmake.define entry or a -DCMAKE_OSX_DEPLOYMENT_TARGET= in cmake.args. Handles both the joined -DVAR=value and the two-token -D VAR=value forms (mirroring parse_generator’s -G handling). The args value wins over the define, mirroring CMake’s own command-line-over-cache precedence. Settings in CMakeLists.txt or a toolchain file cannot be seen here and are not honored.

Return type:

str | None

scikit_build_core.builder.macos.get_macosx_deployment_target(*, arm, cmake_defines=None, cmake_args=())[source]

Get the deployment target used for the wheel platform tag. An explicit CMAKE_OSX_DEPLOYMENT_TARGET from cmake.define or cmake.args wins; otherwise the MACOSX_DEPLOYMENT_TARGET environment variable is used (this is the fallback default CMake itself applies). If neither is set, the current macOS version is used. If arm=True, then this will always return at least (11, 0). Versions after 11 will be normalized to 0 for minor version.

Return type:

MacOSVer

scikit_build_core.builder.macos.normalize_macos_version(version, *, arm)[source]

Set minor version to 0 if major is 11+.

Return type:

MacOSVer

scikit_build_core.builder.sysconfig module

scikit_build_core.builder.sysconfig.get_abi_flags()[source]

Return the ABI flags for the current Python interpreter. Derived from packaging.tags.sys_tags() since that works on Windows.

Return type:

str

scikit_build_core.builder.sysconfig.get_cmake_platform(env)[source]

Return the CMake platform name for a platform, respecting VSCMD_ARG_TGT_ARCH.

Return type:

str

scikit_build_core.builder.sysconfig.get_numpy_include_dir()[source]
Return type:

Path | None

scikit_build_core.builder.sysconfig.get_python_include_dir()[source]
Return type:

Path

scikit_build_core.builder.sysconfig.get_python_library(env, *, abi3=False, abi3t=False)[source]
Return type:

Path | None

scikit_build_core.builder.sysconfig.get_soabi(env, *, abi3=False, abi3t=False)[source]
Return type:

str

scikit_build_core.builder.sysconfig.info_print(*, color='')[source]

Print information about the Python environment.

Return type:

None

scikit_build_core.builder.wheel_tag module

class scikit_build_core.builder.wheel_tag.WheelTag(pyvers, abis, archs, build_tag='')[source]

Bases: object

property abi: str
abis: list[str]
property arch: str
archs: list[str]
as_tags_set()[source]
Return type:

frozenset[Tag]

build_tag: str = ''
classmethod compute_best(archs, py_api='', *, expand_macos=False, root_is_purelib=False, build_tag='', cmake_defines=None, cmake_args=())[source]
Return type:

Self

property pyver: str
pyvers: list[str]
tags_dict()[source]
Return type:

dict[str, list[str]]