Skip to content

tool.cibuildwheel.environment entries are evaluated in order of appearence #2616

@moreati

Description

@moreati

Description

The evaluation of entries in [tool.cibuildwheel.environment] or CIBW_ENVIRONMENT occurs in order of appearence. So

[tool.cibuildwheel.environment]
FOO = "Hello $BAR"
BAR = "World"

results in FOO == "Hello ", rather than "Hello World". $BAR is silently expanded to an empty string.

Discussion

I'm unsure whether this counts as a bug, or a a gotcha. The behaviour is consistent with a sequential execution model (e.g. Python code, Bash code), but not with a declarative model. Is [tool.cibuildwheel.environment] mean to be thought of sequential steps?

If a bug I'm happy to attempt a PR that adds recursive/dependency driven evaluation.
If a gotcha then I'm happy to make a PR that adds documentation and/or a warning at runtime.

Reproduction

Rev moreati/lzma-cf@40a7b8e builds successfully.
Rev moreati/lzma-cf@b730b58 swaps the order of C_INCLUDE_PATH and XZ_UTILS_PREFIX resulting in C_INCLUDE_PATH == "/include:" and a build failure

   gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/build-env-ckg9phoo/include -I/opt/_internal/cpython-3.10.18/include/python3.10 -c build/temp.linux-x86_64-cpython-310/lzma_cf._lzma_cffi.c -o build/temp.linux-x86_64-cpython-310/build/temp.linux-x86_64-cpython-310/lzma_cf._lzma_cffi.o
  build/temp.linux-x86_64-cpython-310/lzma_cf._lzma_cffi.c:577:10: fatal error: lzma.h: No such file or directory
    577 | #include <lzma.h>
        |          ^~~~~~~~
  compilation terminated.
  error: command '/opt/rh/gcc-toolset-14/root/usr/bin/gcc' failed with exit code 1

Build log

https://github.com/moreati/lzma-cf/actions/runs/18340269071/job/52233853421

CI config

https://github.com/moreati/lzma-cf/blob/b730b583a36b173d7ea0a8a416840d3f88d51ad5/pyproject.toml#L58-L65

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions