Skip to content

Commit 279b25a

Browse files
Use Golang compiler binaries (go-bin package) from PyPI (#309)
1 parent 20e1bda commit 279b25a

10 files changed

Lines changed: 98 additions & 125 deletions

File tree

.github/update-hugo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://github.com/gohugoio/hugo/releases/tag/v${LATEST_VERSION}
1212

1313
### Release checklist
1414

15-
- [ ] Check the release notes for any interesting changes, and if the Go version has been updated (if so, update the Go version in `ci.yml` and `cd.yml` manually)
15+
- [ ] Check the release notes for any interesting changes, and if the Go version has been updated (if so, update the Go version in `ci.yml`, `cd.yml`, and `docs/go.mod` manually)
1616
- [ ] Merge this PR
1717
- [ ] Run `nox -s tag -- v${LATEST_VERSION}` locally to create a signed tag
1818
- [ ] Push the tag: `git push origin v${LATEST_VERSION}` — the CD workflow will build and publish the release automatically

.github/workflows/cd.yml

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ jobs:
6464
persist-credentials: false
6565
submodules: recursive
6666

67-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
68-
with:
69-
go-version: "1.26.1"
70-
cache: false
71-
7267
- name: Install MinGW compiler(s)
7368
run: choco install mingw
7469

@@ -102,12 +97,6 @@ jobs:
10297
persist-credentials: false
10398
submodules: recursive
10499

105-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
106-
with:
107-
go-version: "1.26.1"
108-
cache: false
109-
check-latest: true
110-
111100
- name: Resolve Windows Meson cross file
112101
id: meson-cross-file
113102
shell: pwsh
@@ -148,11 +137,6 @@ jobs:
148137
persist-credentials: false
149138
submodules: recursive
150139

151-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
152-
with:
153-
go-version: "1.26.1"
154-
cache: false
155-
156140
- name: Resolve Windows Meson cross file
157141
id: meson-cross-file
158142
shell: pwsh
@@ -199,15 +183,6 @@ jobs:
199183
output-dir: wheelhouse
200184
env:
201185
CIBW_ARCHS_LINUX: x86_64
202-
CIBW_BEFORE_ALL_LINUX: |
203-
tarball="go1.26.1.linux-amd64.tar.gz"
204-
curl -LJO https://golang.org/dl/$tarball
205-
mkdir $HOME/go_installed/
206-
tar -C $HOME/go_installed/ -xzf $tarball
207-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bashrc
208-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bash_profile
209-
go version
210-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
211186
CIBW_TEST_COMMAND: |
212187
hugo version
213188
hugo env --logLevel debug
@@ -236,15 +211,6 @@ jobs:
236211
output-dir: wheelhouse
237212
env:
238213
CIBW_ARCHS_LINUX: aarch64
239-
CIBW_BEFORE_ALL_LINUX: |
240-
tarball="go1.26.1.linux-arm64.tar.gz"
241-
curl -LJO https://golang.org/dl/$tarball
242-
mkdir $HOME/go_installed/
243-
tar -C $HOME/go_installed/ -xzf $tarball
244-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bashrc
245-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bash_profile
246-
go version
247-
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
248214
CIBW_TEST_COMMAND: |
249215
hugo version
250216
hugo env --logLevel debug
@@ -282,14 +248,6 @@ jobs:
282248
output-dir: wheelhouse
283249
env:
284250
CIBW_ARCHS_LINUX: s390x
285-
CIBW_BEFORE_ALL_LINUX: |
286-
tarball="go1.26.1.linux-s390x.tar.gz"
287-
curl -LJO https://golang.org/dl/$tarball
288-
mkdir $HOME/go_installed/
289-
tar -C $HOME/go_installed/ -xzf $tarball
290-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bashrc
291-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bash_profile
292-
go version
293251
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
294252
CIBW_TEST_COMMAND: |
295253
hugo version
@@ -328,14 +286,6 @@ jobs:
328286
output-dir: wheelhouse
329287
env:
330288
CIBW_ARCHS_LINUX: ppc64le
331-
CIBW_BEFORE_ALL_LINUX: |
332-
tarball="go1.26.1.linux-ppc64le.tar.gz"
333-
curl -LJO https://golang.org/dl/$tarball
334-
mkdir $HOME/go_installed/
335-
tar -C $HOME/go_installed/ -xzf $tarball
336-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bashrc
337-
export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bash_profile
338-
go version
339289
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
340290
CIBW_TEST_COMMAND: |
341291
hugo version
@@ -359,12 +309,6 @@ jobs:
359309
persist-credentials: false
360310
submodules: recursive
361311

362-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
363-
with:
364-
go-version: "1.26.1"
365-
cache: false
366-
check-latest: true
367-
368312
- uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
369313
with:
370314
package-dir: .
@@ -393,12 +337,6 @@ jobs:
393337
persist-credentials: false
394338
submodules: recursive
395339

396-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
397-
with:
398-
go-version: "1.26.1"
399-
cache: false
400-
check-latest: true
401-
402340
- uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
403341
with:
404342
package-dir: .

.github/workflows/ci.yml

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
persist-credentials: false
3434

3535
- name: Run style checks
36-
uses: j178/prek-action@6ad80277337ad479fe43bd70701c3f7f8aa74db3 # v2.0.3
36+
uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2.0.4
3737

3838
editable_install:
3939
needs: [style]
@@ -47,26 +47,28 @@ jobs:
4747
persist-credentials: false
4848
submodules: recursive
4949

50-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
50+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
5151
with:
5252
python-version: "3.14"
53+
activate-environment: true
5354

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
55+
- name: Get Go version from pyproject.toml
56+
id: go-version
57+
shell: python
58+
run: |
59+
import re, os
60+
version = re.search(r'go-bin==([0-9.]+)', open('pyproject.toml').read()).group(1)
61+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
62+
f.write(f'version={version}\n')
6163
6264
- name: Restore Hugo builder cache
63-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
65+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
6466
with:
6567
path: ~/.cache/hugo-go
66-
key: editable-install-hugo-${{ runner.os }}-${{ steps.setup-go.outputs.go-version }}
68+
key: editable-install-hugo-${{ runner.os }}-${{ steps.go-version.outputs.version }}
6769

6870
- name: Install Python dependencies
69-
run: python -m pip install nox[uv]
71+
run: uv pip install nox[uv]
7072

7173
- name: Smoke test editable install entry points
7274
run: nox -s editable
@@ -95,18 +97,19 @@ jobs:
9597
persist-credentials: false
9698
submodules: recursive
9799

98-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
100+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
99101
with:
100102
python-version: ${{ matrix.python-version }}
101-
allow-prereleases: true
103+
activate-environment: true
102104

103-
- name: Set up Go toolchain
104-
id: setup-go
105-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
106-
with:
107-
go-version: "1.26.1"
108-
cache: false
109-
check-latest: true
105+
- name: Get Go version from pyproject.toml
106+
id: go-version
107+
shell: python
108+
run: |
109+
import re, os
110+
version = re.search(r'go-bin==([0-9.]+)', open('pyproject.toml').read()).group(1)
111+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
112+
f.write(f'version={version}\n')
110113
111114
- name: Install MinGW on Windows
112115
if: matrix.runs-on == 'windows-latest'
@@ -116,10 +119,10 @@ jobs:
116119
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
117120
with:
118121
path: ~/.cache/hugo-go
119-
key: ${{ matrix.runs-on }}-hugo-${{ steps.setup-go.outputs.go-version }}
122+
key: ${{ matrix.runs-on }}-hugo-${{ steps.go-version.outputs.version }}
120123

121124
- name: Install Python dependencies
122-
run: python -m pip install build virtualenv nox[uv]
125+
run: uv pip install build virtualenv nox[uv]
123126

124127
- name: Build binary distribution (wheel)
125128
run: |
@@ -156,27 +159,28 @@ jobs:
156159
persist-credentials: false
157160
submodules: recursive
158161

159-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
162+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
160163
with:
161164
python-version: ${{ matrix.python-version }}
162-
allow-prereleases: true
165+
activate-environment: true
163166

164-
- name: Set up Go toolchain
165-
id: setup-go
166-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
167-
with:
168-
go-version: "1.26.1"
169-
cache: false
170-
check-latest: true
167+
- name: Get Go version from pyproject.toml
168+
id: go-version
169+
shell: python
170+
run: |
171+
import re, os
172+
version = re.search(r'go-bin==([0-9.]+)', open('pyproject.toml').read()).group(1)
173+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
174+
f.write(f'version={version}\n')
171175
172176
- name: Restore Hugo builder cache
173177
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
174178
with:
175179
path: ~/.cache/hugo-go
176-
key: zig-${{ matrix.runs-on }}-${{ matrix.architecture}}-hugo-experimental-${{ steps.setup-go.outputs.go-version }}
180+
key: zig-${{ matrix.runs-on }}-${{ matrix.architecture}}-hugo-experimental-${{ steps.go-version.outputs.version }}
177181

178182
- name: Install Python dependencies
179-
run: python -m pip install build virtualenv nox auditwheel
183+
run: uv pip install build virtualenv nox auditwheel
180184

181185
- name: Build binary distribution (wheel) on Linux
182186
if: matrix.runs-on == 'ubuntu-latest'
@@ -244,14 +248,14 @@ jobs:
244248
persist-credentials: false
245249
submodules: recursive
246250

247-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
251+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
248252
with:
249-
python-version: 3.14
253+
python-version: "3.14"
250254

251255
- name: Build source distribution (SDist) and binary distribution (wheel)
252256
run: |
253-
pipx run build --sdist --wheel . --outdir dist/
254-
pipx run twine check dist/* --strict
257+
uvx --from build pyproject-build --sdist --wheel . --outdir dist/
258+
uvx twine check dist/* --strict
255259
256260
- name: Check sdist size, fail if it exceeds 10 MiB
257261
run: |
@@ -277,7 +281,7 @@ jobs:
277281
echo -e '\n```\n' >> $GITHUB_STEP_SUMMARY
278282
279283
mkdir -p output/wheel
280-
pipx run wheel unpack dist/*.whl -d output/wheel
284+
uvx --from wheel wheel unpack dist/*.whl -d output/wheel
281285
282286
echo -e '## View binary distribution (wheel) contents\n' >> $GITHUB_STEP_SUMMARY
283287
echo -e '```\n' >> $GITHUB_STEP_SUMMARY

.github/workflows/docs.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,28 @@ jobs:
2828
fetch-depth: 0
2929
submodules: "recursive"
3030

31-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
32-
id: setup-go
33-
with:
34-
go-version: "1.26.1"
35-
cache: false
36-
check-latest: true
31+
- name: Get Go version from pyproject.toml
32+
id: go-version
33+
shell: python
34+
run: |
35+
import re, os
36+
version = re.search(r'go-bin==([0-9.]+)', open('pyproject.toml').read()).group(1)
37+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
38+
f.write(f'version={version}\n')
3739
38-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
40+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
3941
with:
40-
python-version: 3.14
42+
python-version: "3.14"
43+
activate-environment: true
4144

4245
- name: Restore Hugo builder cache
4346
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
4447
with:
4548
path: ./hugo_cache/
46-
key: ubuntu-latest-hugo-${{ steps.setup-go.outputs.go-version }}
49+
key: ubuntu-latest-hugo-${{ steps.go-version.outputs.version }}
4750

4851
- name: Install Python dependencies
49-
run: pip install nox
52+
run: uv pip install nox
5053

5154
- name: Build documentation website
5255
run: nox -s docs
@@ -72,7 +75,7 @@ jobs:
7275
path: docs/public/
7376

7477
- name: Deploy documentation website
75-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
78+
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
7679
with:
7780
github_token: ${{ secrets.GITHUB_TOKEN }}
7881
publish_dir: docs/public/

.github/workflows/update-hugo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
sed -i "s/version\s*:\s*'$CURRENT_VERSION'/version : '$LATEST_VERSION'/" meson.build
6464
6565
# Update the Hugo submodule to the new version tag
66-
cd hugo
66+
cd hugo-src
6767
git fetch origin tag "v$LATEST_VERSION" --no-tags
6868
git checkout "v$LATEST_VERSION"
6969
cd ..
@@ -87,7 +87,7 @@ jobs:
8787
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
8888
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY"
8989
git checkout -b "update-hugo-v${LATEST_VERSION}"
90-
git add meson.build hugo
90+
git add meson.build hugo-src
9191
git commit -m "Update Hugo to v${LATEST_VERSION}"
9292
git push origin "update-hugo-v${LATEST_VERSION}"
9393
gh pr create \

docs/content/building-from-sources.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ toc = true
77

88
The build is driven by [Meson](https://mesonbuild.com/) and [meson-python](https://meson-python.readthedocs.io/). Building the extended + withdeploy edition of Hugo from source requires the following dependencies:
99

10-
1. The [Go](https://go.dev/doc/install) toolchain
11-
2. The [Git](https://git-scm.com/downloads) version control system
12-
3. A C/C++ compiler, such as [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/). You may also use [Zig](https://ziglang.org/) as a C compiler. On Windows, the [MinGW](https://www.mingw-w64.org/) toolchain is supported, and [MSVC](https://visualstudio.microsoft.com/visual-cpp-build-tools/) is untested.
13-
3a. For cross-compilation to non-macOS targets, [Zig](https://ziglang.org/) is pulled in from PyPI and auto-selected as the C compiler. For cross-compilation from macOS hosts to macOS targets, AppleClang is used with `-arch <target>`.
14-
4. [Python](https://www.python.org/downloads/) ≥ 3.10
10+
1. The [Git](https://git-scm.com/downloads) version control system
11+
2. A C/C++ compiler, such as [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/). On Windows, the [MinGW](https://www.mingw-w64.org/) toolchain is supported, and [MSVC](https://visualstudio.microsoft.com/visual-cpp-build-tools/) is untested.
12+
2a. For cross-compilation to non-macOS targets, [Zig](https://ziglang.org/) is pulled in from PyPI and auto-selected as the C compiler. For cross-compilation from macOS hosts to macOS targets, AppleClang is used with `-arch <target>`.
13+
3. [Python](https://www.python.org/downloads/) ≥ 3.10
1514

16-
`meson-python`, `meson`, `ninja`, and `ziglang` are all pulled in as build-time dependencies by the build backend, so you don't have to install them yourself.
15+
`meson-python`, `meson`, `ninja`, `go-bin` (the Go compiler toolchain), and `ziglang` are all pulled in as build-time dependencies automatically by the build backend, so you do not need to install them yourself.
1716

1817
Windows users can use the [Chocolatey package manager](https://chocolatey.org/) in order to use the [MinGW compiler](https://chocolatey.org/packages/mingw). After installing Chocolatey, run the following command in an elevated terminal prompt:
1918

docs/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/agriyakhetarpal/hugo-python-distributions
22

3-
go 1.26.1
3+
go 1.26.3
44

55
require github.com/imfing/hextra v0.12.1 // indirect

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(
22
'hugo-python-distributions',
3-
version : '0.161.1',
3+
version : '0.162.0',
44
meson_version : '>=1.3.0',
55
default_options : ['warning_level=0'],
66
)

0 commit comments

Comments
 (0)