Skip to content

Commit 20e1bda

Browse files
Migrate the build system to Meson/meson-python (#301)
Co-authored-by: Ülgen Sarıkavak <ulgensrkvk@gmail.com>
1 parent aacf10b commit 20e1bda

22 files changed

Lines changed: 865 additions & 822 deletions

.github/workflows/cd.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
path: ./wheelhouse/*.whl
9292
if-no-files-found: error
9393

94-
windows_arm64_wheels: # Not tested
94+
windows_arm64_wheels: # TODO: for later: use windows-11-arm runners as they're available now
9595
name: arm64-windows
9696
runs-on: windows-latest
9797
permissions:
@@ -108,21 +108,25 @@ jobs:
108108
cache: false
109109
check-latest: true
110110

111+
- name: Resolve Windows Meson cross file
112+
id: meson-cross-file
113+
shell: pwsh
114+
run: |
115+
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE 'meson_cross_files/windows-arm64.ini')).Path -replace '\\', '/'
116+
"path=$crossFile" >> $env:GITHUB_OUTPUT
117+
111118
- name: Build binary distribution (wheel) on Windows (arm64)
112119
# We need to use cibuildwheel because it has experimental support for cross-compiling
113120
# to arm64 and setup-python does not have arm64 support on Windows right now
114121
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
115122
with:
116123
package-dir: .
117124
output-dir: wheelhouse
118-
# Cross-compile for arm64 target via Zig toolchain
119125
env:
120-
USE_ZIG: "1"
121-
GOOS: windows
122-
GOARCH: arm64
123126
CIBW_BUILD: "cp312-*"
124127
CIBW_ARCHS_WINDOWS: ARM64
125128
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
129+
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
126130
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
127131
CIBW_TEST_SKIP: "*-win_arm64"
128132

@@ -149,21 +153,23 @@ jobs:
149153
go-version: "1.26.1"
150154
cache: false
151155

152-
# Note: cibuildwheel will manage installing 32-bit Python on Windows. We
153-
# do not need to do that manually unless we use setup-python instead.
156+
- name: Resolve Windows Meson cross file
157+
id: meson-cross-file
158+
shell: pwsh
159+
run: |
160+
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE 'meson_cross_files/windows-386.ini')).Path -replace '\\', '/'
161+
"path=$crossFile" >> $env:GITHUB_OUTPUT
162+
154163
- name: Build binary distribution (wheel) on Windows (i686)
155164
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
156165
with:
157166
package-dir: .
158167
output-dir: wheelhouse
159-
# Cross-compile for i686 target via Zig toolchain
160168
env:
161-
USE_ZIG: "1"
162-
GOOS: windows
163-
GOARCH: 386
164169
CIBW_BUILD: "cp312-*"
165170
CIBW_ARCHS_WINDOWS: x86
166171
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
172+
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
167173
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
168174
CIBW_TEST_COMMAND: |
169175
hugo version

.github/workflows/ci.yml

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,42 @@ jobs:
3535
- name: Run style checks
3636
uses: j178/prek-action@6ad80277337ad479fe43bd70701c3f7f8aa74db3 # v2.0.3
3737

38+
editable_install:
39+
needs: [style]
40+
name: editable-install-smoke
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
steps:
45+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46+
with:
47+
persist-credentials: false
48+
submodules: recursive
49+
50+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
51+
with:
52+
python-version: "3.14"
53+
54+
- name: Set up Go toolchain
55+
id: setup-go
56+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
57+
with:
58+
go-version: "1.26.1"
59+
cache: false
60+
check-latest: true
61+
62+
- name: Restore Hugo builder cache
63+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
64+
with:
65+
path: ~/.cache/hugo-go
66+
key: editable-install-hugo-${{ runner.os }}-${{ steps.setup-go.outputs.go-version }}
67+
68+
- name: Install Python dependencies
69+
run: python -m pip install nox[uv]
70+
71+
- name: Smoke test editable install entry points
72+
run: nox -s editable
73+
3874
build_wheels:
3975
needs: [style]
4076
name: ${{ matrix.runs-on }}-python-${{ matrix.python-version }}
@@ -79,7 +115,7 @@ jobs:
79115
- name: Restore Hugo builder cache
80116
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
81117
with:
82-
path: ./hugo_cache/
118+
path: ~/.cache/hugo-go
83119
key: ${{ matrix.runs-on }}-hugo-${{ steps.setup-go.outputs.go-version }}
84120

85121
- name: Install Python dependencies
@@ -136,40 +172,41 @@ jobs:
136172
- name: Restore Hugo builder cache
137173
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
138174
with:
139-
path: ./hugo_cache/
175+
path: ~/.cache/hugo-go
140176
key: zig-${{ matrix.runs-on }}-${{ matrix.architecture}}-hugo-experimental-${{ steps.setup-go.outputs.go-version }}
141177

142178
- name: Install Python dependencies
143179
run: python -m pip install build virtualenv nox auditwheel
144180

145181
- name: Build binary distribution (wheel) on Linux
146182
if: matrix.runs-on == 'ubuntu-latest'
147-
# Cross-compile for arm64 target via Zig toolchain
148-
env:
149-
USE_ZIG: 1
150-
GOOS: linux
151-
GOARCH: arm64
152-
run: |
153-
python -m build --wheel . --outdir wheelhouse/
183+
run: python -m build --wheel . --outdir wheelhouse -Csetup-args=--cross-file="$GITHUB_WORKSPACE/meson_cross_files/linux-arm64.ini"
154184
# can't repair arm64 wheels on Linux x86_64 right now
155185
# auditwheel repair --plat manylinux_2_28_aarch64 -w wheelhouse/ dist/*.whl
156186

187+
- name: Resolve Windows Meson cross file
188+
if: matrix.runs-on == 'windows-latest'
189+
id: meson-cross-file
190+
shell: pwsh
191+
env:
192+
MATRIX_ARCH: ${{ matrix.architecture }}
193+
run: |
194+
$crossFileName = if ($env:MATRIX_ARCH -eq 'arm64') { 'windows-arm64.ini' } else { 'windows-386.ini' }
195+
$crossFile = (Resolve-Path (Join-Path $env:GITHUB_WORKSPACE "meson_cross_files/$crossFileName")).Path -replace '\\', '/'
196+
"path=$crossFile" >> $env:GITHUB_OUTPUT
197+
157198
- name: Build binary distribution (wheel) on Windows (arm64)
158199
if: matrix.runs-on == 'windows-latest' && matrix.architecture == 'arm64'
159-
# We need to use cibuildwheel because it has experimental support for cross-compiling
160-
# to arm64 and setup-python does not have arm64 support on Windows right now
200+
# TODO: FIXME: use windows-11-arm runners as they're available now, and drop this
161201
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
162202
with:
163203
package-dir: .
164204
output-dir: wheelhouse
165-
# Cross-compile for arm64 target via Zig toolchain
166205
env:
167-
USE_ZIG: "1"
168-
GOOS: windows
169-
GOARCH: arm64
170206
CIBW_BUILD: "cp312-*"
171207
CIBW_ARCHS_WINDOWS: ARM64
172208
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
209+
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
173210
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
174211
CIBW_TEST_SKIP: "*-win_arm64"
175212

@@ -181,14 +218,11 @@ jobs:
181218
with:
182219
package-dir: .
183220
output-dir: wheelhouse
184-
# Cross-compile for i686 target via Zig toolchain
185221
env:
186-
USE_ZIG: "1"
187-
GOOS: windows
188-
GOARCH: 386
189222
CIBW_BUILD: "cp312-*"
190223
CIBW_ARCHS_WINDOWS: x86
191224
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
225+
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=${{ steps.meson-cross-file.outputs.path }}"
192226
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
193227
CIBW_TEST_COMMAND: |
194228
hugo version

.github/workflows/update-hugo.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
set -euo pipefail
2929
30-
CURRENT_VERSION=$(grep -oP 'HUGO_VERSION = "\K[0-9.]+' setup.py)
30+
CURRENT_VERSION=$(grep -oP "version\s*:\s*'\K[0-9.]+" meson.build)
3131
echo "Current version: $CURRENT_VERSION"
3232
3333
# Find the next Hugo release after our current version
@@ -60,8 +60,7 @@ jobs:
6060
RELEASE_TYPE="patch"
6161
fi
6262
63-
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" setup.py
64-
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" src/hugo/cli.py
63+
sed -i "s/version\s*:\s*'$CURRENT_VERSION'/version : '$LATEST_VERSION'/" meson.build
6564
6665
# Update the Hugo submodule to the new version tag
6766
cd hugo
@@ -88,7 +87,7 @@ jobs:
8887
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
8988
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY"
9089
git checkout -b "update-hugo-v${LATEST_VERSION}"
91-
git add setup.py src/hugo/cli.py hugo
90+
git add meson.build hugo
9291
git commit -m "Update Hugo to v${LATEST_VERSION}"
9392
git push origin "update-hugo-v${LATEST_VERSION}"
9493
gh pr create \

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ src/hugo/binaries/*
182182
# Hugo builder cache
183183
hugo_cache/
184184

185-
# Hugo version file
186-
hugo/VERSION
187-
188185
# Documentation
189186
/docs/public
190187
/docs/resources
191188
*.lock
192189

193190
# Generated stamp file for sdist builds
194-
hugo/.hugo_commit_date
191+
hugo-src/.hugo_commit_date
192+
193+
# Generated by meson configure_file
194+
src/hugo/_version.py

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "hugo"]
2-
path = hugo
2+
path = hugo-src
33
url = https://github.com/gohugoio/hugo.git

MANIFEST.in

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)