Skip to content

Commit d41723d

Browse files
Use cibuildwheel v4.1 (#320)
1 parent 4031adb commit d41723d

4 files changed

Lines changed: 65 additions & 151 deletions

File tree

.github/workflows/cd.yml

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ on:
1010

1111
env:
1212
FORCE_COLOR: 3
13-
CIBW_BUILD_FRONTEND: "build"
14-
CIBW_BUILD: "cp312-*"
15-
CIBW_SKIP: "pp* *musllinux*"
1613

1714
permissions: {}
1815

@@ -71,13 +68,6 @@ jobs:
7168
with:
7269
package-dir: .
7370
output-dir: wheelhouse
74-
env:
75-
CIBW_ARCHS_WINDOWS: AMD64
76-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
77-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
78-
CIBW_TEST_COMMAND: |
79-
hugo version
80-
hugo env --logLevel debug
8171

8272
- name: Upload wheels
8373
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -97,27 +87,12 @@ jobs:
9787
persist-credentials: false
9888
submodules: recursive
9989

100-
- name: Resolve Windows Meson cross file
101-
id: meson-cross-file
102-
shell: pwsh
103-
run: |
104-
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE 'meson_cross_files/windows-arm64.ini')).Path -replace '\\', '/'
105-
"path=$crossFile" >> $env:GITHUB_OUTPUT
106-
10790
- name: Build binary distribution (wheel) on Windows (arm64)
10891
# We need to use cibuildwheel because it has experimental support for cross-compiling
10992
# to arm64 and setup-python does not have arm64 support on Windows right now
11093
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
111-
with:
112-
package-dir: .
113-
output-dir: wheelhouse
11494
env:
115-
CIBW_BUILD: "cp312-*"
11695
CIBW_ARCHS_WINDOWS: ARM64
117-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
118-
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
119-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
120-
CIBW_TEST_SKIP: "*-win_arm64"
12196

12297
- name: Upload wheels
12398
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -128,7 +103,7 @@ jobs:
128103

129104
windows_i686_wheels:
130105
name: i686-windows
131-
runs-on: windows-2025
106+
runs-on: windows-latest
132107
permissions:
133108
contents: read
134109
steps:
@@ -137,27 +112,10 @@ jobs:
137112
persist-credentials: false
138113
submodules: recursive
139114

140-
- name: Resolve Windows Meson cross file
141-
id: meson-cross-file
142-
shell: pwsh
143-
run: |
144-
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE 'meson_cross_files/windows-386.ini')).Path -replace '\\', '/'
145-
"path=$crossFile" >> $env:GITHUB_OUTPUT
146-
147115
- name: Build binary distribution (wheel) on Windows (i686)
148116
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
149-
with:
150-
package-dir: .
151-
output-dir: wheelhouse
152117
env:
153-
CIBW_BUILD: "cp312-*"
154118
CIBW_ARCHS_WINDOWS: x86
155-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
156-
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
157-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
158-
CIBW_TEST_COMMAND: |
159-
hugo version
160-
hugo env --logLevel debug
161119

162120
- name: Upload wheels
163121
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -181,11 +139,6 @@ jobs:
181139
with:
182140
package-dir: .
183141
output-dir: wheelhouse
184-
env:
185-
CIBW_ARCHS_LINUX: x86_64
186-
CIBW_TEST_COMMAND: |
187-
hugo version
188-
hugo env --logLevel debug
189142

190143
- name: Upload wheels
191144
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -209,11 +162,6 @@ jobs:
209162
with:
210163
package-dir: .
211164
output-dir: wheelhouse
212-
env:
213-
CIBW_ARCHS_LINUX: aarch64
214-
CIBW_TEST_COMMAND: |
215-
hugo version
216-
hugo env --logLevel debug
217165

218166
- name: Upload wheels
219167
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -243,15 +191,8 @@ jobs:
243191

244192
- name: Build binary distribution (wheel) on Linux (s390x)
245193
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
246-
with:
247-
package-dir: .
248-
output-dir: wheelhouse
249194
env:
250195
CIBW_ARCHS_LINUX: s390x
251-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
252-
CIBW_TEST_COMMAND: |
253-
hugo version
254-
hugo env --logLevel debug
255196

256197
- name: Upload wheels
257198
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -274,22 +215,11 @@ jobs:
274215
- uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
275216
with:
276217
platforms: all
277-
# This should be temporary
278-
# xref https://github.com/docker/setup-qemu-action/issues/188
279-
# xref https://github.com/tonistiigi/binfmt/issues/215
280-
image: tonistiigi/binfmt:qemu-v8.1.5
281218

282219
- name: Build binary distribution (wheel) on Linux (ppc64le)
283220
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
284-
with:
285-
package-dir: .
286-
output-dir: wheelhouse
287221
env:
288222
CIBW_ARCHS_LINUX: ppc64le
289-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
290-
CIBW_TEST_COMMAND: |
291-
hugo version
292-
hugo env --logLevel debug
293223

294224
- name: Upload wheels
295225
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -313,11 +243,6 @@ jobs:
313243
with:
314244
package-dir: .
315245
output-dir: wheelhouse
316-
env:
317-
CIBW_ARCHS_MACOS: x86_64
318-
CIBW_TEST_COMMAND: |
319-
hugo version
320-
hugo env --logLevel debug
321246

322247
- name: Upload wheels
323248
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -341,11 +266,6 @@ jobs:
341266
with:
342267
package-dir: .
343268
output-dir: wheelhouse
344-
env:
345-
CIBW_ARCHS_MACOS: arm64
346-
CIBW_TEST_COMMAND: |
347-
hugo version
348-
hugo env --logLevel debug
349269

350270
- name: Upload wheels
351271
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/ci.yml

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ concurrency:
1616

1717
env:
1818
FORCE_COLOR: 3
19-
CIBW_SKIP: "pp* *musllinux*"
20-
CIBW_BUILD_FRONTEND: "build"
2119

2220
permissions: {}
2321

@@ -82,24 +80,16 @@ jobs:
8280
persist-credentials: false
8381
submodules: recursive
8482

85-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
86-
with:
87-
python-version: ${{ matrix.python-version }}
88-
activate-environment: true
89-
90-
- name: Install MinGW on Windows
83+
- name: Install MinGW compiler(s) on Windows
9184
if: matrix.runs-on == 'windows-latest'
9285
run: choco install mingw
9386

94-
- name: Install Python dependencies
95-
run: uv pip install build virtualenv nox[uv]
96-
97-
- name: Build binary distribution (wheel)
98-
run: |
99-
python -m build --wheel . --outdir wheelhouse/
100-
101-
- name: Test entry points for package
102-
run: nox -s venv
87+
- uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
88+
with:
89+
package-dir: .
90+
output-dir: wheelhouse
91+
env:
92+
CIBW_BUILD: "cp${{ matrix.python-version == '3.10' && '310' || matrix.python-version == '3.13' && '313' || '314' }}-*"
10393

10494
# TODO: add aarch64 to x86_64 cross-compilation for Linux
10595
experimental:
@@ -129,30 +119,25 @@ jobs:
129119
persist-credentials: false
130120
submodules: recursive
131121

132-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
133-
with:
134-
python-version: ${{ matrix.python-version }}
135-
activate-environment: true
136-
137-
- name: Install Python dependencies
138-
run: uv pip install build virtualenv nox auditwheel
139-
140122
- name: Build binary distribution (wheel) on Linux
141123
if: matrix.runs-on == 'ubuntu-latest'
142-
run: python -m build --wheel . --outdir wheelhouse -Csetup-args=--cross-file="$GITHUB_WORKSPACE/meson_cross_files/linux-arm64.ini"
143124
# can't repair arm64 wheels on Linux x86_64 right now
144125
# auditwheel repair --plat manylinux_2_28_aarch64 -w wheelhouse/ dist/*.whl
145-
146-
- name: Resolve Windows Meson cross file
147-
if: matrix.runs-on == 'windows-latest'
148-
id: meson-cross-file
149-
shell: pwsh
126+
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
127+
with:
128+
package-dir: .
129+
output-dir: wheelhouse
150130
env:
151-
MATRIX_ARCH: ${{ matrix.architecture }}
152-
run: |
153-
$crossFileName = if ($env:MATRIX_ARCH -eq 'arm64') { 'windows-arm64.ini' } else { 'windows-386.ini' }
154-
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE "meson_cross_files/$crossFileName")).Path -replace '\\', '/'
155-
"path=$crossFile" >> $env:GITHUB_OUTPUT
131+
CIBW_BUILD: "cp${{ matrix.python-version == '3.10' && '310' || matrix.python-version == '3.13' && '313' || '314' }}-*"
132+
CIBW_ARCHS_LINUX: x86_64
133+
# This job lies about the arch (x86_64 container, aarch64 wheel via the
134+
# cross file), so its build identifier collides with the native x86_64
135+
# build and can't be selected in a pyproject override. Keep the cross
136+
# settings here, and disable the global test-command and repair: the
137+
# aarch64 wheel can neither run nor be repaired on x86_64.
138+
CIBW_CONFIG_SETTINGS_LINUX: "setup-args=--cross-file={project}/meson_cross_files/linux-arm64.ini"
139+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ""
140+
CIBW_TEST_COMMAND: ""
156141

157142
- name: Build binary distribution (wheel) on Windows (arm64)
158143
if: matrix.runs-on == 'windows-latest' && matrix.architecture == 'arm64'
@@ -162,12 +147,7 @@ jobs:
162147
package-dir: .
163148
output-dir: wheelhouse
164149
env:
165-
CIBW_BUILD: "cp312-*"
166150
CIBW_ARCHS_WINDOWS: ARM64
167-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
168-
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
169-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
170-
CIBW_TEST_SKIP: "*-win_arm64"
171151

172152
# Note: cibuildwheel will manage installing 32-bit Python on Windows. We
173153
# do not need to do that manually unless we use setup-python instead.
@@ -178,14 +158,7 @@ jobs:
178158
package-dir: .
179159
output-dir: wheelhouse
180160
env:
181-
CIBW_BUILD: "cp312-*"
182161
CIBW_ARCHS_WINDOWS: x86
183-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
184-
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
185-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
186-
CIBW_TEST_COMMAND: |
187-
hugo version
188-
hugo env --logLevel debug
189162

190163
- name: Upload artifacts for debugging
191164
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

noxfile.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ def lint(session: nox.Session) -> None:
2424
session.run("prek", "-a", *session.posargs)
2525

2626

27-
@nox.session(name="venv", reuse_venv=True)
28-
def venv(session: nox.Session) -> None:
29-
"""Create a virtual environment and install wheels from a specified folder into it."""
30-
folder = "dist" if session.interactive else "wheelhouse"
31-
session.log(f"Installing wheels from {folder}")
32-
for file in DIR.joinpath(folder).glob("*.whl"):
33-
session.install(file)
34-
session.run("hugo", "version")
35-
session.run("hugo", "env", "--logLevel", "debug")
36-
37-
3827
@nox.session(default=False, reuse_venv=True)
3928
def editable(session: nox.Session) -> None:
4029
"""Smoke test console and module entry points from an editable install."""
@@ -45,17 +34,6 @@ def editable(session: nox.Session) -> None:
4534
session.run("hugo", "version")
4635

4736

48-
def _get_version(session: nox.Session) -> str:
49-
"""Extract version from session posargs or meson.build."""
50-
if session.posargs:
51-
return session.posargs[0].lstrip("v")
52-
content = (DIR / "meson.build").read_text()
53-
match = re.search(r"version\s*:\s*'([0-9.]+)'", content)
54-
if not match:
55-
session.error("Could not determine version. Pass it as: nox -s tag -- 0.157.0")
56-
return match.group(1)
57-
58-
5937
@nox.session(default=False, reuse_venv=True)
6038
def docs(session: nox.Session) -> None:
6139
"""Build the documentation website.
@@ -70,6 +48,17 @@ def docs(session: nox.Session) -> None:
7048
session.run("hugo", "--minify", "--source", str(DOCS_DIR))
7149

7250

51+
def _get_version(session: nox.Session) -> str:
52+
"""Extract version from session posargs or meson.build."""
53+
if session.posargs:
54+
return session.posargs[0].lstrip("v")
55+
content = (DIR / "meson.build").read_text()
56+
match = re.search(r"version\s*:\s*'([0-9.]+)'", content)
57+
if not match:
58+
session.error("Could not determine version. Pass it as: nox -s tag -- 0.157.0")
59+
return match.group(1)
60+
61+
7362
@nox.session(default=False)
7463
def tag(session: nox.Session) -> None:
7564
"""Create a signed, annotated tag for a release.

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,38 @@ hugo = "hugo.cli:__call"
5959
[tool.meson-python]
6060
allow-windows-internal-shared-libs = true
6161

62+
[tool.cibuildwheel]
63+
# CI overrides CIBW_BUILD to also exercise the build on other interpreters
64+
# but since we are shipping a none-any wheel this doesn't matter for local
65+
# builds as we don't want to build multiple wheels
66+
build = "cp314-*"
67+
skip = "*musllinux*"
68+
test-command = """
69+
hugo version
70+
hugo env --logLevel debug
71+
"""
72+
# arm64 wheels are cross-compiled from the x86_64 runner and cannot run there
73+
test-skip = "*-win_arm64"
74+
75+
[tool.cibuildwheel.windows]
76+
# auto would also build 32-bit x86 on a 64-bit runner. That target is
77+
# cross-compiled in its own job, so let's keep native Windows builds as AMD64 only.
78+
archs = ["AMD64"]
79+
80+
# cross-compile the Windows arm64 wheel with the matching Meson cross file
81+
# Switch back to {project} once https://github.com/pypa/cibuildwheel/pull/2934
82+
# makes it to a release
83+
[[tool.cibuildwheel.overrides]]
84+
select = "*-win_arm64"
85+
config-settings = { setup-args = "--cross-file={package}/meson_cross_files/windows-arm64.ini" }
86+
87+
# cross-compile the Windows 32-bit (x86) wheel with the matching Meson cross file
88+
[[tool.cibuildwheel.overrides]]
89+
select = "*-win32"
90+
# Switch back to {project} once https://github.com/pypa/cibuildwheel/pull/2934
91+
# makes it to a release
92+
config-settings = { setup-args = "--cross-file={package}/meson_cross_files/windows-386.ini" }
93+
6294
[tool.ruff]
6395
src = ["src"]
6496
lint.extend-select = [

0 commit comments

Comments
 (0)