Skip to content

feat: add CIBUILDWHEEL_BUILD_IDENTIFIER environment variable#2872

Merged
henryiii merged 2 commits into
pypa:mainfrom
henryiii:henryiii/feat/build-identifier-env-var
May 29, 2026
Merged

feat: add CIBUILDWHEEL_BUILD_IDENTIFIER environment variable#2872
henryiii merged 2 commits into
pypa:mainfrom
henryiii:henryiii/feat/build-identifier-env-var

Conversation

@henryiii
Copy link
Copy Markdown
Contributor

@henryiii henryiii commented May 27, 2026

🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖

Summary

Closes #944, closes #2750.

Sets a new environment variable CIBUILDWHEEL_BUILD_IDENTIFIER to the current build identifier (e.g. cp311-manylinux_x86_64) in the environment for all per-build steps: before_build, the build itself, repair_command, before_test, and test_command.

Motivation

Users need to inspect the current build identifier inside scripts and commands, for example to write per-build output files without one build overwriting another:

[tool.cibuildwheel]
test-command = "pytest --junit-xml=results-$CIBUILDWHEEL_BUILD_IDENTIFIER.xml"

Design decisions

  • Set after the user's CIBW_ENVIRONMENT overrides are applied, so it reliably reflects the actual identifier.
  • Available only for per-build steps — not in before_all, where no single identifier applies (that step runs once for a batch of builds).
  • Covers all six platforms: linux, macOS, Windows, pyodide, Android, and iOS.

Assisted-by: CopilotCLI:claude-sonnet-4.6

Set `CIBUILDWHEEL_BUILD_IDENTIFIER` to the current build identifier
(e.g. `cp311-manylinux_x86_64`) in the environment for all per-build
steps: `before_build`, the build itself, `repair_command`,
`before_test`, and `test_command`.

This allows scripts and commands to inspect which build is currently
running, which is useful for e.g. writing per-build output files:

    CIBW_TEST_COMMAND='pytest --junit-xml=results-$CIBUILDWHEEL_BUILD_IDENTIFIER.xml'

The variable is set after the user's environment overrides are applied
and is only available for per-build steps (not `before_all`, where no
single identifier applies). All six platforms are covered: linux, macOS,
Windows, pyodide, Android, and iOS.

Closes pypa#944, closes pypa#2750

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: OpenCode:claude-sonnet-4.6
Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

Copy link
Copy Markdown
Contributor

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The utility of script-based builds is always going to be slightly limited on iOS, but the example of an argument to pytest would definitely apply, and the general approach is straightforward.

Comment thread cibuildwheel/platforms/android.py Outdated
Assisted-by: OpenCode:glm-5.1
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii henryiii merged commit 80d5810 into pypa:main May 29, 2026
45 checks passed
@henryiii henryiii deleted the henryiii/feat/build-identifier-env-var branch May 29, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants