Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The override system

Slides

The basics

This allows you to override the settings in [tool.scikit-build] based on the environment that is building the package.

A simple example is

[[tool.scikit-build.overrides]]
if.env.WITH_MPI = "ON"
cmake.define.BUILD_MPI = true

which checks for an environment variable WITH_MPI and then populates the -DBUILD_MPI CMake define.

The latest documentation of this feature can be found at the Configuration/Overrides page

Example situations

Here are some scenarios of where and how you could use this to get you inspired:

How it works

All if.* conditionals are and glued. If you need or glued conditionals instead, use if.any.* as needed. The current if.* conditionals available are:

where the regex, version, bool conditionals check if the variable matches the provided regex pattern, version specifier, boolean state respectively.

Then you provide any variables you would provide for tool.scikit-build to override. By default, a table (e.g. cmake.define) is completely replaced. inherit.* can be used to merge the table with overrides on top of original (append) or vice-versa (prepend). For example

if does not match
no inherit
inherit append
inherit prepend
[tool.scikit-build]
cmake.define.BUILD_MPI = false
cmake.define.BUILD_TESTS = false

[[tool.scikit-build.overrides]]
if.env.WITH_MPI = "ON"
cmake.define.BUILD_MPI = true
cmake.define.MPI_PROC = "2"

If environment variable WITH_MPI is not defined, it is equivalent to

[tool.scikit-build]
cmake.define.BUILD_MPI = false
cmake.define.BUILD_TESTS = false