Skip to content

Commit 68eb3ad

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 d0a1743 commit 68eb3ad

3 files changed

Lines changed: 78 additions & 4 deletions

File tree

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- wheels-*
88
tags:
99
- 'v*'
10+
workflow_dispatch: # REMOVE THIS BEFORE PR
1011

1112
jobs:
1213
build_wheels:
@@ -21,9 +22,19 @@ jobs:
2122
os: ubuntu-24.04-arm
2223
- name: macos
2324
os: macos-13
25+
- name: windows-x64
26+
os: windows-latest
27+
- name: windows-x32
28+
os: windows-latest
29+
- name: windows-arm64
30+
# https://github.com/actions/partner-runner-images#available-images
31+
os: windows-11-arm
2432

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

2839
- uses: actions/setup-python@v6
2940
with:
@@ -33,7 +44,9 @@ jobs:
3344
run: python -m pip install cibuildwheel~=3.1.1
3445

3546
- name: Build wheels
36-
run: python -m cibuildwheel --output-dir wheelhouse
47+
run: >-
48+
python -m cibuildwheel --output-dir wheelhouse
49+
${{ matrix.name == 'windows-x32' && '--archs=auto32' }}
3750
3851
- uses: actions/upload-artifact@v4
3952
with:
@@ -45,7 +58,10 @@ jobs:
4558
runs-on: ubuntu-24.04
4659

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

5066
- uses: actions/setup-python@v6
5167
with:
@@ -69,13 +85,30 @@ jobs:
6985
name: wheels-linux-ppc
7086
path: ./wheelhouse/*.whl
7187

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

77110
steps:
78-
- uses: actions/download-artifact@v4
111+
- uses: actions/download-artifact@v5
79112
with:
80113
path: dist
81114
pattern: wheels-*

β€Žbuild.ps1β€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if (Test-Path -Path $env:LIBGIT2_SRC) {
2+
Set-Location $env:LIBGIT2_SRC
3+
if (Test-Path -Path build) {
4+
Remove-Item -Recurse -Force build
5+
}
6+
git fetch --depth=1 --tags
7+
git checkout v$env:LIBGIT2_VERSION
8+
} else {
9+
git clone --depth=1 -b v$env:LIBGIT2_VERSION https://github.com/libgit2/libgit2.git $env:LIBGIT2_SRC
10+
Set-Location $env:LIBGIT2_SRC
11+
}
12+
cmake -B build -S . -DBUILD_TESTS=OFF
13+
cmake --build build/ --config=Release --target install

β€Žpyproject.tomlβ€Ž

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,34 @@ 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+
before-all = "powershell -File build.ps1"
30+
31+
[[tool.cibuildwheel.overrides]]
32+
select="*-win_amd64"
33+
inherit.environment="append"
34+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
35+
environment.CMAKE_GENERATOR_PLATFORM = "x64"
36+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_x86_64"
37+
environment.LIBGIT2 = "C:/libgit2_install_x86_64"
38+
39+
[[tool.cibuildwheel.overrides]]
40+
select="*-win32"
41+
inherit.environment="append"
42+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
43+
environment.CMAKE_GENERATOR_PLATFORM = "Win32"
44+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_x86"
45+
environment.LIBGIT2 = "C:/libgit2_install_x86"
46+
47+
[[tool.cibuildwheel.overrides]]
48+
select="*-win_arm64"
49+
inherit.environment="append"
50+
environment.CMAKE_GENERATOR = "Visual Studio 17 2022"
51+
environment.CMAKE_GENERATOR_PLATFORM = "ARM64"
52+
environment.CMAKE_INSTALL_PREFIX = "C:/libgit2_install_arm64"
53+
environment.LIBGIT2 = "C:/libgit2_install_arm64"
54+
2755
[tool.ruff]
2856
extend-exclude = [ ".cache", ".coverage", "build", "site-packages", "venv*"]
2957
target-version = "py310" # oldest supported Python version

0 commit comments

Comments
Β (0)