From d593457f6079e7f3c1a316ceebf1be69930804da Mon Sep 17 00:00:00 2001 From: TT <70463940+Herrtian@users.noreply.github.com> Date: Mon, 4 May 2026 22:08:55 +0200 Subject: [PATCH] Document platform-specific before-build config (#2834) * Document platform-specific before-build config * Update docs/options.md Co-authored-by: agriya khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> * Align before-build examples across config formats --------- Co-authored-by: Henry Schreiner Co-authored-by: agriya khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- docs/options.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/options.md b/docs/options.md index fd84d83c..7e916cad 100644 --- a/docs/options.md +++ b/docs/options.md @@ -793,6 +793,8 @@ The command is run in a shell, so you can write things like `cmd1 && cmd2`. Platform-specific environment variables are also available:
`CIBW_BEFORE_BUILD_MACOS` | `CIBW_BEFORE_BUILD_WINDOWS` | `CIBW_BEFORE_BUILD_LINUX` | `CIBW_BEFORE_BUILD_ANDROID` | `CIBW_BEFORE_BUILD_IOS` | `CIBW_BEFORE_BUILD_PYODIDE` +In configuration files, use platform tables like `[tool.cibuildwheel.macos]`. + #### Examples !!! tab examples "pyproject.toml" @@ -816,6 +818,13 @@ Platform-specific environment variables are also available:
# If cibuildwheel is called with a package_dir argument, it's available as {package} before-build = "{package}/script/prepare_for_build.sh" + + # Use a different command on a specific platform + [tool.cibuildwheel.linux] + before-build = "python scripts/install-linux-deps.py" + + [tool.cibuildwheel.macos] + before-build = "python scripts/install-macos-deps.py" ``` In configuration files, you can use a array, and the items will be joined @@ -836,6 +845,10 @@ Platform-specific environment variables are also available:
# If cibuildwheel is called with a package_dir argument, it's available as {package} CIBW_BEFORE_BUILD: "{package}/script/prepare_for_build.sh" + + # Use a different command on a specific platform + CIBW_BEFORE_BUILD_LINUX: python scripts/install-linux-deps.py + CIBW_BEFORE_BUILD_MACOS: python scripts/install-macos-deps.py ```