fix(ci): wrong wheel version on Windows (#308)

use first-time setuptools-scm detected version to avoid leftover dir incfluence subsequent wheel version detection
This commit is contained in:
Jalin Wang 2026-04-03 14:51:35 +08:00 committed by GitHub
parent 2cb1a146fb
commit ae13e9541b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 20 deletions

View File

@ -65,6 +65,10 @@ jobs:
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -products * -prerelease -format json
shell: powershell
- name: Enable git long paths
shell: powershell
run: git config --global core.longpaths true
- name: Checkout code
uses: actions/checkout@v6
with:
@ -86,31 +90,33 @@ jobs:
with:
arch: x64
- name: Install cibuildwheel
run: |
pip install --upgrade pip
pip install cibuildwheel==3.4.0
- name: Add Git bin to PATH
run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
shell: powershell
- name: Cache built wheels
id: cache-wheels
uses: actions/cache@v4
with:
path: wheelhouse
key: ${{ runner.os }}-wheels-${{ hashFiles('**/pyproject.toml', '**/setup.py', '**/*.py', '**/*.c', '**/*.cpp') }}
# - name: Cache built wheels
# id: cache-wheels
# uses: actions/cache@v4
# with:
# path: wheelhouse
# key: ${{ runner.os }}-wheels-${{ hashFiles('**/pyproject.toml', '**/setup.py', '**/*.py', '**/*.c', '**/*.cpp') }}
- name: Build wheels using cibuildwheel
if: steps.cache-wheels.outputs.cache-hit != 'true'
# if: steps.cache-wheels.outputs.cache-hit != 'true'
shell: powershell
# env:
# CIBW_BUILD_VERBOSITY: 1
# CIBW_DEBUG_TRACEBACK: 1
# CIBW_DEBUG_KEEP_CONTAINER: 1
run: |
# 1. Generate and capture the version from setuptools_scm
pip install --upgrade pip
pip install cibuildwheel==3.4.0
pip install setuptools-scm>=8.0
$SCM_VERSION = python -m setuptools_scm
echo "Detected Version: $SCM_VERSION"
# 2. Set it as an environment variable for the current shell and subsequent steps
$env:SETUPTOOLS_SCM_PRETEND_VERSION = $SCM_VERSION
# 3. Run cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Install and test wheel
@ -190,6 +196,11 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Smoke test from PyPI
shell: powershell
env:
@ -217,7 +228,7 @@ jobs:
$PSNativeCommandUseErrorActionPreference = $false
$found = $false
for ($i = 1; $i -le 30; $i++) {
python -m pip install --force-reinstall @indexArgs --dry-run "zvec==$version" 1>$null 2>$null
python -m pip install --force-reinstall @indexArgs --dry-run "zvec==$version"
if ($LASTEXITCODE -eq 0) {
Write-Host "Version $version is available."
$found = $true

View File

@ -189,9 +189,13 @@ environment = { CMAKE_GENERATOR = "Unix Makefiles", CMAKE_BUILD_PARALLEL_LEVEL =
[tool.cibuildwheel.windows]
archs = ["auto64"]
test-command = "cd /d {project} && pytest python/tests -v --tb=short --basetemp=./.pytest_tmp && if exist .pytest_tmp rmdir /s /q .pytest_tmp"
test-command = "cd /d {project} && pytest python/tests -v --tb=short --basetemp=./.pytest_tmp"
environment = { CMAKE_GENERATOR = "Ninja" }
config-settings = { build-dir = "build/{wheel_tag}" }
#config-settings = { build-dir = "build/{wheel_tag}" }
#&& if exist .pytest_tmp rmdir /s /q .pytest_tmp"
before-build = [
"python -c \"import shutil, glob, os; [shutil.rmtree(p, ignore_errors=True) for p in ['build', '.pytest_tmp']];\""
]
######################################################################################################
# CODE QUALITY & FORMATTING (Ruff)