Skip to content

Commit 95e6430

Browse files
wmaynerclaude
andcommitted
fix: Pass version to cibuildwheel via SETUPTOOLS_SCM_PRETEND_VERSION
Inside cibuildwheel containers, git tags aren't visible so setuptools_scm falls back to 0.0.0. Fix by extracting version from git tag before building and passing it via environment variable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 361c3fc commit 95e6430

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.github/workflows/build_wheels.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ jobs:
2626
with:
2727
python-version: '3.12'
2828

29+
- name: Get version from git tag
30+
id: version
31+
run: |
32+
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
33+
echo "version=$VERSION" >> $GITHUB_OUTPUT
34+
echo "Building version: $VERSION"
35+
2936
- name: Install cibuildwheel
3037
run: pip install cibuildwheel>=3.0
3138

3239
- name: Build wheels
3340
run: cibuildwheel --output-dir wheelhouse
41+
env:
42+
CIBW_ENVIRONMENT: "SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.version.outputs.version }}"
3443

3544
- uses: actions/upload-artifact@v4
3645
with:

.github/workflows/make_sdist.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ jobs:
2121
with:
2222
python-version: '3.12'
2323

24+
- name: Get version from git tag
25+
id: version
26+
run: |
27+
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Building version: $VERSION"
30+
2431
- name: Build source distribution
2532
run: |
2633
pip install build
2734
python -m build --sdist
35+
env:
36+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }}
2837

2938
- uses: actions/upload-artifact@v4
3039
with:

0 commit comments

Comments
 (0)