Ray's Knowledge Base
Unlock

A cibuildwheel Linux build does not see host env vars, so a forwarded version variable is empty

PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

One CI run uploads two PyPI releases of the same commit. The Linux wheels have a different version than the macOS wheels, for example 0.0.12.post1.dev131 (Linux) and 0.0.12.post131.dev0 (macOS).

Cause#

Linux cibuildwheel builds run in a container. The container does not see the host environment. A line like SETUPTOOLS_SCM_PRETEND_VERSION_FOR_<DIST>: $SETUPTOOLS_SCM_PRETEND_VERSION_FOR_<DIST> in CIBW_ENVIRONMENT expands to an empty string there. setuptools-scm then falls back to the no-guess-dev scheme and computes its own version. macOS builds run on the host, so the variable works there.

Fix#

Name the variable in CIBW_ENVIRONMENT_PASS_LINUX, for example CIBW_ENVIRONMENT_PASS_LINUX: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DFTRACER_UTILS.

Evidence#

Seen in the dftracer-utils wheel workflow: one run produced the versions 0.0.12.post1.dev131 and 0.0.12.post131.dev0, which became two releases on PyPI.

Also found by searching

  • cibuildwheel Linux wheels 0.0.12.post1.dev131 but macOS wheels 0.0.12.post131.dev0 from the same commit
  • one CI run published two different PyPI versions of the same commit, Linux wheels ignore my pretend version env var
  • how do I pass SETUPTOOLS_SCM_PRETEND_VERSION into the cibuildwheel manylinux container?
  • CIBW_ENVIRONMENT $VAR expands empty inside docker on Linux, environment not forwarded to the build container
  • cibuildwheel Linux wheel version differs from macOS wheel, SETUPTOOLS_SCM_PRETEND_VERSION empty in CIBW_ENVIRONMENT
  • one CI run uploaded two different PyPI versions of the same commit, linux .post1.dev131 vs mac .post131.dev0
  • how do I pass an environment variable into the cibuildwheel manylinux container?
  • setuptools-scm pretend version not applied inside docker for cibuildwheel linux builds