Skip to content

Commit ae13e95

Browse files
authored
fix(ci): wrong wheel version on Windows (#308)
use first-time setuptools-scm detected version to avoid leftover dir incfluence subsequent wheel version detection
1 parent 2cb1a14 commit ae13e95

2 files changed

Lines changed: 35 additions & 20 deletions

File tree

.github/workflows/build_wheel_on_windows.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ jobs:
6565
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -products * -prerelease -format json
6666
shell: powershell
6767

68+
- name: Enable git long paths
69+
shell: powershell
70+
run: git config --global core.longpaths true
71+
6872
- name: Checkout code
6973
uses: actions/checkout@v6
7074
with:
@@ -86,31 +90,33 @@ jobs:
8690
with:
8791
arch: x64
8892

89-
- name: Install cibuildwheel
90-
run: |
91-
pip install --upgrade pip
92-
pip install cibuildwheel==3.4.0
93-
9493
- name: Add Git bin to PATH
9594
run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
9695
shell: powershell
9796

98-
- name: Cache built wheels
99-
id: cache-wheels
100-
uses: actions/cache@v4
101-
with:
102-
path: wheelhouse
103-
key: ${{ runner.os }}-wheels-${{ hashFiles('**/pyproject.toml', '**/setup.py', '**/*.py', '**/*.c', '**/*.cpp') }}
97+
# - name: Cache built wheels
98+
# id: cache-wheels
99+
# uses: actions/cache@v4
100+
# with:
101+
# path: wheelhouse
102+
# key: ${{ runner.os }}-wheels-${{ hashFiles('**/pyproject.toml', '**/setup.py', '**/*.py', '**/*.c', '**/*.cpp') }}
104103

105104
- name: Build wheels using cibuildwheel
106-
if: steps.cache-wheels.outputs.cache-hit != 'true'
105+
# if: steps.cache-wheels.outputs.cache-hit != 'true'
107106
shell: powershell
108-
# env:
109-
# CIBW_BUILD_VERBOSITY: 1
110-
# CIBW_DEBUG_TRACEBACK: 1
111-
# CIBW_DEBUG_KEEP_CONTAINER: 1
112-
113107
run: |
108+
# 1. Generate and capture the version from setuptools_scm
109+
pip install --upgrade pip
110+
pip install cibuildwheel==3.4.0
111+
pip install setuptools-scm>=8.0
112+
113+
$SCM_VERSION = python -m setuptools_scm
114+
echo "Detected Version: $SCM_VERSION"
115+
116+
# 2. Set it as an environment variable for the current shell and subsequent steps
117+
$env:SETUPTOOLS_SCM_PRETEND_VERSION = $SCM_VERSION
118+
119+
# 3. Run cibuildwheel
114120
python -m cibuildwheel --output-dir wheelhouse
115121
116122
- name: Install and test wheel
@@ -190,6 +196,11 @@ jobs:
190196
runs-on: ${{ matrix.platform }}
191197

192198
steps:
199+
- name: Set up Python
200+
uses: actions/setup-python@v6
201+
with:
202+
python-version: ${{ matrix.python-version }}
203+
193204
- name: Smoke test from PyPI
194205
shell: powershell
195206
env:
@@ -217,7 +228,7 @@ jobs:
217228
$PSNativeCommandUseErrorActionPreference = $false
218229
$found = $false
219230
for ($i = 1; $i -le 30; $i++) {
220-
python -m pip install --force-reinstall @indexArgs --dry-run "zvec==$version" 1>$null 2>$null
231+
python -m pip install --force-reinstall @indexArgs --dry-run "zvec==$version"
221232
if ($LASTEXITCODE -eq 0) {
222233
Write-Host "Version $version is available."
223234
$found = $true

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,13 @@ environment = { CMAKE_GENERATOR = "Unix Makefiles", CMAKE_BUILD_PARALLEL_LEVEL =
189189

190190
[tool.cibuildwheel.windows]
191191
archs = ["auto64"]
192-
test-command = "cd /d {project} && pytest python/tests -v --tb=short --basetemp=./.pytest_tmp && if exist .pytest_tmp rmdir /s /q .pytest_tmp"
192+
test-command = "cd /d {project} && pytest python/tests -v --tb=short --basetemp=./.pytest_tmp"
193193
environment = { CMAKE_GENERATOR = "Ninja" }
194-
config-settings = { build-dir = "build/{wheel_tag}" }
194+
#config-settings = { build-dir = "build/{wheel_tag}" }
195+
#&& if exist .pytest_tmp rmdir /s /q .pytest_tmp"
196+
before-build = [
197+
"python -c \"import shutil, glob, os; [shutil.rmtree(p, ignore_errors=True) for p in ['build', '.pytest_tmp']];\""
198+
]
195199

196200
######################################################################################################
197201
# CODE QUALITY & FORMATTING (Ruff)

0 commit comments

Comments
 (0)