Skip to content

Commit 098cbe3

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. - add job to build sdist (for sake of completeness) - update README.md badges
1 parent 0645936 commit 098cbe3

File tree

4 files changed

+114
-8
lines changed

4 files changed

+114
-8
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@ jobs:
2121
os: ubuntu-24.04-arm
2222
- name: macos
2323
os: macos-13
24+
- name: windows-x64
25+
os: windows-latest
26+
- name: windows-x86
27+
os: windows-latest
28+
- name: windows-arm64
29+
# https://github.com/actions/partner-runner-images#available-images
30+
os: windows-11-arm
2431

2532
steps:
2633
- uses: actions/checkout@v5
34+
with:
35+
# avoid leaking credentials in uploaded artifacts
36+
persist-credentials: false
2737

2838
- uses: actions/setup-python@v6
2939
with:
@@ -33,6 +43,8 @@ jobs:
3343
run: python -m pip install cibuildwheel~=3.1.1
3444

3545
- name: Build wheels
46+
env:
47+
CIBW_ARCHS_WINDOWS: ${{ matrix.name == 'windows-x86' && 'auto32' || 'native' }}
3648
run: python -m cibuildwheel --output-dir wheelhouse
3749

3850
- uses: actions/upload-artifact@v4
@@ -46,6 +58,9 @@ jobs:
4658

4759
steps:
4860
- uses: actions/checkout@v5
61+
with:
62+
# avoid leaking credentials in uploaded artifacts
63+
persist-credentials: false
4964

5065
- uses: actions/setup-python@v6
5166
with:
@@ -69,6 +84,43 @@ jobs:
6984
name: wheels-linux-ppc
7085
path: ./wheelhouse/*.whl
7186

87+
sdist:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v5
91+
with:
92+
# avoid leaking credentials in uploaded artifacts
93+
persist-credentials: false
94+
95+
- uses: actions/setup-python@v6
96+
with:
97+
python-version: '3.13'
98+
99+
- name: Build sdist
100+
run: pipx run build --sdist --outdir dist
101+
102+
- uses: actions/upload-artifact@v4
103+
with:
104+
name: wheels-sdist
105+
path: dist/*
106+
107+
twine-check:
108+
name: Twine check
109+
# It is good to do this check on non-tagged commits.
110+
# Note, pypa/gh-action-pypi-publish (see job below) does this automatically.
111+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
112+
needs: [build_wheels, build_wheels_ppc, sdist]
113+
runs-on: ubuntu-latest
114+
115+
steps:
116+
- uses: actions/download-artifact@v5
117+
with:
118+
path: dist
119+
pattern: wheels-*
120+
merge-multiple: true
121+
- name: check distribution files
122+
run: pipx run twine check dist/*
123+
72124
pypi:
73125
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
74126
needs: [build_wheels, build_wheels_ppc]

β€ŽREADME.mdβ€Ž

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
Bindings to the libgit2 shared library, implements Git plumbing.
44
Supports Python 3.10 to 3.13 and PyPy3 7.3+
55

6-
[![image](https://github.com/libgit2/pygit2/actions/workflows/tests.yml/badge.svg)](https://github.com/libgit2/pygit2/actions/workflows/tests.yml)
6+
[![test-ci-badge][test-ci-badge]][test-ci-link]
7+
[![deploy-ci-badge][deploy-ci-badge]][deploy-ci-link]
78

8-
[![image](https://ci.appveyor.com/api/projects/status/edmwc0dctk5nacx0/branch/master?svg=true)](https://ci.appveyor.com/project/jdavid/pygit2/branch/master)
9+
[deploy-ci-badge]: https://github.com/libgit2/pygit2/actions/workflows/wheels.yml/badge.svg
10+
[deploy-ci-link]: https://github.com/libgit2/pygit2/actions/workflows/wheels.yml
11+
[test-ci-badge]: https://github.com/libgit2/pygit2/actions/workflows/tests.yml/badge.svg
12+
[test-ci-link]: https://github.com/libgit2/pygit2/actions/workflows/tests.yml
913

1014
## Links
1115

12-
- Documentation - <https://www.pygit2.org/>
13-
- Install - <https://www.pygit2.org/install.html>
14-
- Download - <https://pypi.org/project/pygit2/>
15-
- Source code and issue tracker - <https://github.com/libgit2/pygit2>
16-
- Changelog - <https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md>
17-
- Authors - <https://github.com/libgit2/pygit2/blob/master/AUTHORS.md>
16+
- Documentation - <https://www.pygit2.org/>
17+
- Install - <https://www.pygit2.org/install.html>
18+
- Download - <https://pypi.org/project/pygit2/>
19+
- Source code and issue tracker - <https://github.com/libgit2/pygit2>
20+
- Changelog - <https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md>
21+
- Authors - <https://github.com/libgit2/pygit2/blob/master/AUTHORS.md>
1822

1923
## Sponsors
2024

β€Ž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)