Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d031c07
Add template `meson.build`
agriyakhetarpal Apr 25, 2026
af44227
Delete setuptools-related files
agriyakhetarpal Apr 25, 2026
21577e7
Just make the binary "hugo" or "hugo.exe"
agriyakhetarpal Apr 25, 2026
4ae548f
Add Hugo version template + Python files
agriyakhetarpal Apr 25, 2026
7f805cb
Remove more setuptools metadata
agriyakhetarpal Apr 25, 2026
41a7b34
Add meson-python as build backend
agriyakhetarpal Apr 25, 2026
98540ae
Start script to build Hugo
agriyakhetarpal Apr 25, 2026
a25684e
Setup Zig, build Hugo, swap correct build date
agriyakhetarpal Apr 25, 2026
5533e50
Override meson-python for build backend
agriyakhetarpal Apr 25, 2026
9019d1b
Change location of Hugo cache storage
agriyakhetarpal Apr 25, 2026
f445608
Rename meson wrapper file
agriyakhetarpal Apr 25, 2026
1fb5b2d
Generate some cross files
agriyakhetarpal Apr 25, 2026
220b75c
Add config settings to use cross files + TODOs
agriyakhetarpal Apr 25, 2026
a7275ca
Fix path to build backend
agriyakhetarpal Apr 25, 2026
cb10e5e
Fix Hugo version update process
agriyakhetarpal Apr 25, 2026
0717760
Change submodule location
agriyakhetarpal Apr 25, 2026
76c8906
Delete wheel committed by error
agriyakhetarpal Apr 25, 2026
69c2715
Add submodule at new location
agriyakhetarpal Apr 25, 2026
f6d144d
Add a job to test editable installations
agriyakhetarpal Apr 25, 2026
cce6c65
Make the sdist smaller
agriyakhetarpal Apr 25, 2026
ba30349
Add use_zig mappings and Hugo custom_target
agriyakhetarpal Apr 25, 2026
42f441a
Update CLI paths for Hugo executable
agriyakhetarpal Apr 25, 2026
d0d09dc
Ignore generated version file
agriyakhetarpal Apr 25, 2026
a70288f
Try setting path to cross file
agriyakhetarpal Apr 25, 2026
e226c76
Stop meson-python from Windows internal libs check
agriyakhetarpal Apr 25, 2026
d361dd1
Test editable build with Python 3.14
agriyakhetarpal Apr 25, 2026
d414544
Point to generated cross files correctly
agriyakhetarpal Apr 25, 2026
4cef2a0
Fix win32 cross file + fix paths to cross files
agriyakhetarpal Apr 25, 2026
8c4ae9b
Try `github.workspace`
agriyakhetarpal Apr 25, 2026
f6e2f18
Work around Windows Meson cross file stuff...
agriyakhetarpal Apr 25, 2026
d15b18d
Fix lint
agriyakhetarpal Apr 25, 2026
0546e02
Try to resolve different Hugo executables
agriyakhetarpal Apr 25, 2026
943f122
Make editable session verbose
agriyakhetarpal Apr 25, 2026
3ce50f6
Fix Python 3.10 joinpath mess
agriyakhetarpal Apr 25, 2026
e34f372
Fix wrong zig-windows-amd64-to-arm64 wheel tag
agriyakhetarpal Apr 25, 2026
9a2f099
Try to make auditwheel happy
agriyakhetarpal Apr 26, 2026
dd20e6e
Force the platform tag in `get_platform_tag` to be correct
agriyakhetarpal Apr 26, 2026
d70881a
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] Apr 26, 2026
3150bcb
Merge branch 'main' into meson-python!
agriyakhetarpal Apr 26, 2026
202832a
Debug: try something
agriyakhetarpal Apr 26, 2026
3965988
Revert "Debug: try something"
agriyakhetarpal Apr 26, 2026
8d3d588
Revert "Try to make auditwheel happy"
agriyakhetarpal Apr 26, 2026
b0a80ac
Install binary to `datadir`, pick it using `sysconfig`
agriyakhetarpal Apr 26, 2026
d72d177
Update docs
agriyakhetarpal Apr 26, 2026
a2dba63
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] Apr 26, 2026
1748319
Merge branch 'main' into meson-python!
agriyakhetarpal Apr 30, 2026
ef37cea
Bump version
agriyakhetarpal Apr 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.13
python-version: 3.14

- name: Build source distribution
run: pipx run build --sdist --outdir dist/
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
path: ./wheelhouse/*.whl
if-no-files-found: error

windows_arm64_wheels: # Not tested
windows_arm64_wheels: # TODO: for later: use windows-11-arm runners as they're available now
name: arm64-windows
runs-on: windows-latest
permissions:
Expand All @@ -115,14 +115,11 @@ jobs:
with:
package-dir: .
output-dir: wheelhouse
# Cross-compile for arm64 target via Zig toolchain
env:
USE_ZIG: "1"
GOOS: windows
GOARCH: arm64
CIBW_BUILD: "cp312-*"
CIBW_ARCHS_WINDOWS: ARM64
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=meson_cross_files/windows-arm64.ini"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_SKIP: "*-win_arm64"

Expand All @@ -149,21 +146,16 @@ jobs:
go-version: "1.26.1"
cache: false

# Note: cibuildwheel will manage installing 32-bit Python on Windows. We
# do not need to do that manually unless we use setup-python instead.
- name: Build binary distribution (wheel) on Windows (i686)
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
with:
package-dir: .
output-dir: wheelhouse
# Cross-compile for i686 target via Zig toolchain
env:
USE_ZIG: "1"
GOOS: windows
GOARCH: 386
CIBW_BUILD: "cp312-*"
CIBW_ARCHS_WINDOWS: x86
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=meson_cross_files/windows-386.ini"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: |
hugo version
Expand Down
63 changes: 43 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,42 @@ jobs:
- name: Run style checks
uses: j178/prek-action@53276d8b0d10f8b6672aa85b4588c6921d0370cc # v2.0.1

editable_install:
needs: [style]
name: editable-install-smoke
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: recursive

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
Comment thread
agriyakhetarpal marked this conversation as resolved.
Outdated

- name: Set up Go toolchain
id: setup-go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.1"
cache: false
check-latest: true

- name: Restore Hugo builder cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ~/.cache/hugo-go
key: editable-install-hugo-${{ runner.os }}-${{ steps.setup-go.outputs.go-version }}

- name: Install Python dependencies
run: python -m pip install nox[uv]

- name: Smoke test editable install entry points
run: nox -s editable

build_wheels:
needs: [style]
name: ${{ matrix.runs-on }}-python-${{ matrix.python-version }}
Expand Down Expand Up @@ -79,7 +115,7 @@ jobs:
- name: Restore Hugo builder cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ./hugo_cache/
path: ~/.cache/hugo-go
key: ${{ matrix.runs-on }}-hugo-${{ steps.setup-go.outputs.go-version }}

- name: Install Python dependencies
Expand Down Expand Up @@ -136,40 +172,30 @@ jobs:
- name: Restore Hugo builder cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ./hugo_cache/
path: ~/.cache/hugo-go
key: zig-${{ matrix.runs-on }}-${{ matrix.architecture}}-hugo-experimental-${{ steps.setup-go.outputs.go-version }}

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

- name: Build binary distribution (wheel) on Linux
if: matrix.runs-on == 'ubuntu-latest'
# Cross-compile for arm64 target via Zig toolchain
env:
USE_ZIG: 1
GOOS: linux
GOARCH: arm64
run: |
python -m build --wheel . --outdir wheelhouse/
run: python -m build --wheel . --outdir wheelhouse -Csetup-args=--cross-file=$PWD/meson_cross_files/linux-arm64.ini
# can't repair arm64 wheels on Linux x86_64 right now
# auditwheel repair --plat manylinux_2_28_aarch64 -w wheelhouse/ dist/*.whl

- name: Build binary distribution (wheel) on Windows (arm64)
if: matrix.runs-on == 'windows-latest' && matrix.architecture == 'arm64'
# We need to use cibuildwheel because it has experimental support for cross-compiling
# to arm64 and setup-python does not have arm64 support on Windows right now
# TODO: FIXME: use windows-11-arm runners as they're available now, and drop this
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
with:
package-dir: .
output-dir: wheelhouse
# Cross-compile for arm64 target via Zig toolchain
env:
USE_ZIG: "1"
GOOS: windows
GOARCH: arm64
CIBW_BUILD: "cp312-*"
CIBW_ARCHS_WINDOWS: ARM64
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=meson_cross_files/windows-arm64.ini"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_SKIP: "*-win_arm64"

Expand All @@ -181,14 +207,11 @@ jobs:
with:
package-dir: .
output-dir: wheelhouse
# Cross-compile for i686 target via Zig toolchain
env:
USE_ZIG: "1"
GOOS: windows
GOARCH: 386
CIBW_BUILD: "cp312-*"
CIBW_ARCHS_WINDOWS: x86
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--cross-file=meson_cross_files/windows-686.ini"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: |
hugo version
Expand All @@ -212,7 +235,7 @@ jobs:

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
python-version: 3.14

- name: Build source distribution (SDist) and binary distribution (wheel)
run: |
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/update-hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
set -euo pipefail

CURRENT_VERSION=$(grep -oP 'HUGO_VERSION = "\K[0-9.]+' setup.py)
CURRENT_VERSION=$(grep -oP "version\s*:\s*'\K[0-9.]+" meson.build)
echo "Current version: $CURRENT_VERSION"

# Find the next Hugo release after our current version
Expand Down Expand Up @@ -60,8 +60,7 @@ jobs:
RELEASE_TYPE="patch"
fi

sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" setup.py
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" src/hugo/cli.py
sed -i "s/version\s*:\s*'$CURRENT_VERSION'/version : '$LATEST_VERSION'/" meson.build

# Update the Hugo submodule to the new version tag
cd hugo
Expand All @@ -88,7 +87,7 @@ jobs:
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY"
git checkout -b "update-hugo-v${LATEST_VERSION}"
git add setup.py src/hugo/cli.py hugo
git add meson.build hugo
git commit -m "Update Hugo to v${LATEST_VERSION}"
git push origin "update-hugo-v${LATEST_VERSION}"
gh pr create \
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ src/hugo/binaries/*
# Hugo builder cache
hugo_cache/

# Hugo version file
hugo/VERSION

# Documentation
/docs/public
/docs/resources
*.lock

# Generated stamp file for sdist builds
hugo/.hugo_commit_date
hugo-src/.hugo_commit_date

# Generated by meson configure_file
src/hugo/_version.py
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "hugo"]
path = hugo
path = hugo-src
url = https://github.com/gohugoio/hugo.git
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

105 changes: 105 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
project(
'hugo-python-distributions',
version : '0.160.1',
meson_version : '>=1.3.0',
default_options : ['warning_level=0'],
)

# Setting `pure: true` routes the Python package (including the bundled Hugo
# executable) to purelib, so platlib stays empty. Combined with the marker file
# installed into libdir below, this keeps the wheel tag at py3-none-<platform>
# instead of a Python-version-specific ABI tag.
# See _has_extension_modules and _pure in mesonpy/__init__.py
py = import('python').find_installation(pure: true)

go = find_program('go', required: true)
git = find_program('git', required: true)

configure_file(
input : 'src/hugo/_version.py.in',
output : '_version.py',
configuration : { 'HUGO_VERSION' : meson.project_version() },
install : true,
install_dir : py.get_install_dir() / 'hugo',
install_tag : 'python-runtime',
)

py.install_sources(
['src/hugo/__main__.py', 'src/hugo/cli.py'],
subdir : 'hugo',
)

host_sys = host_machine.system()
host_cpu = host_machine.cpu_family()
exe_suffix = host_sys == 'windows' ? '.exe' : ''

# Map meson's host_machine values to Golang's GOOS/GOARCH values
# for cross-compilation
GOOS_MAP = {
'linux' : 'linux',
'darwin' : 'darwin',
'windows' : 'windows',
}
GOARCH_MAP = {
'x86_64' : 'amd64',
'aarch64' : 'arm64',
'arm' : 'arm',
'x86' : '386',
'ppc64' : 'ppc64le',
's390x' : 's390x',
'riscv64' : 'riscv64',
}
if not GOOS_MAP.has_key(host_sys)
error('Unsupported host_machine.system: ' + host_sys)
endif
if not GOARCH_MAP.has_key(host_cpu)
error('Unsupported host_machine.cpu_family: ' + host_cpu)
endif
goos = GOOS_MAP[host_sys]
goarch = GOARCH_MAP[host_cpu]

# Use Zig when cross-compiling, except for the "macOS arm64 to macOS x86_64"
# case where Zig lacks the macOS SDK and cannot find libresolv.dylib. For that
# we rely on the system linker as it is where AppleClang has native support
# for cross-compilation. This can still be overridden by setting the use_zig
# option to true or false explicitly.
auto_use_zig = meson.is_cross_build() and host_sys != 'darwin'
use_zig_opt = get_option('use_zig')
use_zig = use_zig_opt.auto() ? auto_use_zig : use_zig_opt.enabled()


custom_target(
'hugo-binary',
output : 'hugo' + exe_suffix, # must match src/hugo/cli.py
command : [
py.full_path(),
files('scripts/build_hugo.py'),
'--hugo-src', meson.project_source_root() / 'hugo-src',
'--cache', meson.project_build_root() / 'hugo_cache',
'--version', meson.project_version(),
'--output', '@OUTPUT@',
'--use-zig', use_zig.to_string(),
'--goos', goos,
'--goarch', goarch,
],
install : true,
install_dir : py.get_install_dir() / 'hugo' / 'binaries',
install_tag : 'python-runtime',
build_by_default : true,
console : true,
)

# This is a hack to make meson-python mark the wheel as non-pure regardless
# of whether the host platform's magic-number check in mesonpy._is_native
# matches the target binary. _pure becomes False whenever mesonpy-libs
# ({libdir}) is non-empty, without running _is_native on its contents. See
#_WheelBuilder._pure in mesonpy/__init__.py.
configure_file(
output : '.platform_marker',
configuration : configuration_data(),
install : true,
install_dir : get_option('libdir'),
install_tag : 'runtime',
)

meson.add_dist_script(py.full_path(), files('scripts/prune_sdist.py'))
6 changes: 6 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
option(
'use_zig',
type : 'feature',
value : 'auto',
description : 'Use ziglang as the CGO cross-compiler. "auto" picks Zig when cross-compiling to a non-darwin target.',
)
5 changes: 5 additions & 0 deletions meson_cross_files/linux-arm64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'
5 changes: 5 additions & 0 deletions meson_cross_files/windows-386.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
5 changes: 5 additions & 0 deletions meson_cross_files/windows-arm64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[host_machine]
system = 'windows'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'
Loading
Loading