Skip to content

Commit e181502

Browse files
committed
feat: build windows distributions with cibuildwheel in GH CI
Should avoid maintaining appveyor workflow (and free up appveyor account limitations πŸ˜‰). This also introduces windows aarch64 distributions πŸŽ‰ Lastly, I updated other spots in the GH actions workflow: - upgrade `actions/checkout` to v5 (only breaking changes are internal like upgrade node version used for building their dist) - turn off credential persistence in `actions/checkout` action (only useful if the workflow uses `git push` or similar) - upgrade `actions/download-artifact` to v5 (only breaking changes are internal because this already uses `merge-multiple: true`) - add job to check built distributions for non-tagged commits to default branch. This is meant to highlight any problems with dists' metadata before tagging a release.
1 parent 5f655b7 commit e181502

3 files changed

Lines changed: 87 additions & 3 deletions

File tree

β€Ž.github/workflows/wheels.ymlβ€Ž

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- wheels-*
88
tags:
99
- 'v*'
10+
pull_request: # REMOVE THIS BEFORE PR
11+
branches: [master]
1012

1113
jobs:
1214
build_wheels:
@@ -21,9 +23,19 @@ jobs:
2123
os: ubuntu-24.04-arm
2224
- name: macos
2325
os: macos-13
26+
- name: windows-x64
27+
os: windows-latest
28+
- name: windows-x32
29+
os: windows-latest
30+
- name: windows-arm64
31+
# https://github.com/actions/partner-runner-images#available-images
32+
os: windows-11-arm
2433

2534
steps:
26-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v5
36+
with:
37+
# avoid leaking credentials in uploaded artifacts
38+
persist-credentials: false
2739

2840
- uses: actions/setup-python@v6
2941
with:
@@ -33,6 +45,8 @@ jobs:
3345
run: python -m pip install cibuildwheel~=3.1.1
3446

3547
- name: Build wheels
48+
env:
49+
CIBW_ARCHS_WINDOWS: ${{ matrix.name == 'windows-x32' && 'auto32' || 'native' }}
3650
run: python -m cibuildwheel --output-dir wheelhouse
3751

3852
- uses: actions/upload-artifact@v4
@@ -45,7 +59,10 @@ jobs:
4559
runs-on: ubuntu-24.04
4660

4761
steps:
48-
- uses: actions/checkout@v4
62+
- uses: actions/checkout@v5
63+
with:
64+
# avoid leaking credentials in uploaded artifacts
65+
persist-credentials: false
4966

5067
- uses: actions/setup-python@v6
5168
with:
@@ -69,13 +86,30 @@ jobs:
6986
name: wheels-linux-ppc
7087
path: ./wheelhouse/*.whl
7188

89+
twine-check:
90+
name: Twine check
91+
# It is good to do this check on non-tagged commits.
92+
# Note, pypa/gh-action-pypi-publish (see job below) does this automatically.
93+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
94+
needs: [build_wheels, build_wheels_ppc]
95+
runs-on: ubuntu-latest
96+
97+
steps:
98+
- uses: actions/download-artifact@v5
99+
with:
100+
path: dist
101+
pattern: wheels-*
102+
merge-multiple: true
103+
- name: check distribution files
104+
run: pipx run twine check dist/*
105+
72106
pypi:
73107
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
74108
needs: [build_wheels, build_wheels_ppc]
75109
runs-on: ubuntu-24.04
76110

77111
steps:
78-
- uses: actions/download-artifact@v4
112+
- uses: actions/download-artifact@v5
79113
with:
80114
path: dist
81115
pattern: wheels-*

β€Žbuild.ps1β€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if (!(Test-Path -Path "build")) {
2+
# in case the pygit2 package build/ workspace has not been created by cibuildwheel yet
3+
mkdir build
4+
}
5+
if (Test-Path -Path "$env:LIBGIT2_SRC") {
6+
Set-Location "$env:LIBGIT2_SRC"
7+
# for local runs, reuse build/libgit_src if it exists
8+
if (Test-Path -Path build) {
9+
# purge previous build env (likely for a different arch type)
10+
Remove-Item -Recurse -Force build
11+
}
12+
# ensure we are checked out to the right version
13+
git fetch --depth=1 --tags
14+
git checkout "v$env:LIBGIT2_VERSION"
15+
} else {
16+
# from a fresh run (like in CI)
17+
git clone --depth=1 -b "v$env:LIBGIT2_VERSION" https://github.com/libgit2/libgit2.git $env:LIBGIT2_SRC
18+
Set-Location "$env:LIBGIT2_SRC"
19+
}
20+
cmake -B build -S . -DBUILD_TESTS=OFF
21+
cmake --build build/ --config=Release --target install

β€Žpyproject.tomlβ€Ž

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ archs = ["universal2"]
2424
environment = {LIBGIT2_VERSION="1.9.1", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSION="3.3.3", LIBGIT2="/Users/runner/work/pygit2/pygit2/ci"}
2525
repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
2626

27+
[tool.cibuildwheel.windows]
28+
environment.LIBGIT2_SRC = "build/libgit2_src"
29+
environment.LIBGIT2_VERSION = "1.9.1"
30+
before-all = "powershell -File build.ps1"
31+
32+
[[tool.cibuildwheel.overrides]]
33+
select="*-win_amd64"
34+
inherit.environment="append"
35+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
36+
environment.CMAKE_GENERATOR_PLATFORM = "x64"
37+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_x86_64"
38+
environment.LIBGIT2 = "C:/libgit2_install_x86_64"
39+
40+
[[tool.cibuildwheel.overrides]]
41+
select="*-win32"
42+
inherit.environment="append"
43+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
44+
environment.CMAKE_GENERATOR_PLATFORM = "Win32"
45+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_x86"
46+
environment.LIBGIT2 = "C:/libgit2_install_x86"
47+
48+
[[tool.cibuildwheel.overrides]]
49+
select="*-win_arm64"
50+
inherit.environment="append"
51+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
52+
environment.CMAKE_GENERATOR_PLATFORM = "ARM64"
53+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_arm64"
54+
environment.LIBGIT2 = "C:/libgit2_install_arm64"
55+
2756
[tool.ruff]
2857
extend-exclude = [ ".cache", ".coverage", "build", "site-packages", "venv*"]
2958
target-version = "py310" # oldest supported Python version

0 commit comments

Comments
Β (0)