From de7e10c7db52d2b403ce7900223e8467f128acb3 Mon Sep 17 00:00:00 2001 From: Amp Date: Tue, 11 Aug 2026 08:30:57 +0000 Subject: [PATCH] Document option inheritance across configuration layers Amp-Thread-ID: https://ampcode.com/threads/T-019fefe0-6bbb-736e-b01c-d7f15d2db320 Co-authored-by: Joe Rickerby --- docs/configuration.md | 89 ++++++++++++++++++++++++++++++++++--------- docs/options.md | 12 ++++-- 2 files changed, 80 insertions(+), 21 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 552772eb..6a357638 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -66,10 +66,11 @@ placed in `[tool.cibuildwheel]` and are lower case, with dashes, following common [TOML](https://toml.io) practice. Anything placed in subsections named after a platform will only affect those platforms. Platform-specific values replace the corresponding global value for that platform; table options -are not merged key by key. Lists can be used instead of strings for items that -are naturally a list. Multiline strings also work just like in the environment -variables. Environment variable overrides, such as `CIBW_TEST_COMMAND` and -`CIBW_TEST_COMMAND_LINUX`, will take precedence if defined. +are not merged key by key unless you configure [inheritance](#inherit). Lists can +be used instead of strings for items that are naturally a list. Multiline strings +also work just like in the environment variables. Environment variable overrides, +such as `CIBW_TEST_COMMAND` and `CIBW_TEST_COMMAND_LINUX`, take precedence if +defined. The example above using environment variables could have been written like this: @@ -113,9 +114,9 @@ trigger new containers, one per image. The ``output-dir``, ``build``, ``skip``, ``test_skip`` selectors, and architectures cannot be overridden. -You can specify a table of overrides in `inherit={}`, any list or table in this -list will inherit from previous overrides or the main configuration. The valid -options are `"none"` (the default), `"append"`, and `"prepend"`. +By default, values in an override replace values from the main configuration or +earlier overrides. You can instead [extend a list or table option](#inherit) by +setting an `inherit` rule for it. #### Examples: @@ -175,14 +176,50 @@ This example will provide the command `"pyproject-before && pyproject && pyproje on Python 3.11, and will have `environment = {FOO="BAZ", "PYTHON"="MONTY", "HAM"="EGGS"}`. -## Extending existing options {: #inherit } +## Option inheritance {: #inherit } -In the TOML configuration, you can choose how tables and lists are inherited. -By default, all values are overridden completely (`"none"`) but sometimes you'd -rather `"append"` or `"prepend"` to an existing list or table. You can do this -with the `inherit` table in overrides. For example, if you want to add an environment -variable for CPython 3.11, without `inherit` you'd have to repeat all the -original environment variables in the override. With `inherit`, it's just: +As cibuildwheel reads its configuration, each layer normally replaces the value +from the previous layer. The layers, from lowest to highest precedence, are: + +1. cibuildwheel's defaults +2. `[tool.cibuildwheel]` +3. `[tool.cibuildwheel.]` +4. matching `[[tool.cibuildwheel.overrides]]` entries, in order +5. `CIBW_