Skip to content

Commit 5d501e2

Browse files
Switch to a submodule for building Hugo (#272)
* Add more architecture mappings * Move to an `src/` format package * Add `hugo` as a submodule * Prune the sdist and make it smaller * Check out repository with submodules too * Update Hugo submodule tag for release update PRs * Fail if sdist size exceeds 10 MiB * Update instructions for building from sources * Drop Hugo git-clone step from setup * Ensure sdist builds can get an accurate build time * Git-ignore the build timestamp file * Some more fixes... * Claude can try too * More fixes from Claude
1 parent 78d297d commit 5d501e2

13 files changed

Lines changed: 222 additions & 44 deletions

File tree

.github/workflows/cd.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2727
with:
2828
persist-credentials: false
29+
submodules: recursive
2930

3031
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3132
with:
@@ -34,6 +35,18 @@ jobs:
3435
- name: Build source distribution
3536
run: pipx run build --sdist --outdir dist/
3637

38+
- name: Check sdist size, fail if it exceeds 10 MiB
39+
run: |
40+
MAX_SIZE_MB=10
41+
SDIST=$(ls dist/*.tar.gz)
42+
SIZE=$(stat --format=%s "$SDIST")
43+
SIZE_MB=$(awk "BEGIN {printf \"%.2f\", $SIZE / 1048576}")
44+
echo "sdist size: ${SIZE_MB} MB"
45+
if [ "$SIZE" -gt $((MAX_SIZE_MB * 1048576)) ]; then
46+
echo "::error::sdist is ${SIZE_MB} MB, exceeding the ${MAX_SIZE_MB} MB limit"
47+
exit 1
48+
fi
49+
3750
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
3851
with:
3952
name: source_distribution
@@ -49,6 +62,7 @@ jobs:
4962
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5063
with:
5164
persist-credentials: false
65+
submodules: recursive
5266

5367
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
5468
with:
@@ -86,6 +100,7 @@ jobs:
86100
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
87101
with:
88102
persist-credentials: false
103+
submodules: recursive
89104

90105
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
91106
with:
@@ -127,6 +142,7 @@ jobs:
127142
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
128143
with:
129144
persist-credentials: false
145+
submodules: recursive
130146

131147
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
132148
with:
@@ -169,6 +185,7 @@ jobs:
169185
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
170186
with:
171187
persist-credentials: false
188+
submodules: recursive
172189

173190
- uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
174191
with:
@@ -205,6 +222,7 @@ jobs:
205222
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
206223
with:
207224
persist-credentials: false
225+
submodules: recursive
208226

209227
- uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
210228
with:
@@ -241,6 +259,7 @@ jobs:
241259
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
242260
with:
243261
persist-credentials: false
262+
submodules: recursive
244263

245264
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
246265
with:
@@ -286,6 +305,7 @@ jobs:
286305
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
287306
with:
288307
persist-credentials: false
308+
submodules: recursive
289309

290310
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
291311
with:
@@ -331,6 +351,7 @@ jobs:
331351
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
332352
with:
333353
persist-credentials: false
354+
submodules: recursive
334355

335356
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
336357
with:
@@ -364,6 +385,7 @@ jobs:
364385
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
365386
with:
366387
persist-credentials: false
388+
submodules: recursive
367389

368390
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
369391
with:

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
with:
3030
persist-credentials: false
31+
submodules: recursive
3132

3233
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3334
with:
@@ -58,6 +59,7 @@ jobs:
5859
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5960
with:
6061
persist-credentials: false
62+
submodules: recursive
6163

6264
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
6365
with:
@@ -118,6 +120,7 @@ jobs:
118120
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
119121
with:
120122
persist-credentials: false
123+
submodules: recursive
121124

122125
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
123126
with:
@@ -207,6 +210,7 @@ jobs:
207210
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
208211
with:
209212
persist-credentials: false
213+
submodules: recursive
210214

211215
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
212216
with:
@@ -217,6 +221,18 @@ jobs:
217221
pipx run build --sdist --wheel . --outdir dist/
218222
pipx run twine check dist/* --strict
219223
224+
- name: Check sdist size, fail if it exceeds 10 MiB
225+
run: |
226+
MAX_SIZE_MB=10
227+
SDIST=$(ls dist/*.tar.gz)
228+
SIZE=$(stat --format=%s "$SDIST")
229+
SIZE_MB=$(awk "BEGIN {printf \"%.2f\", $SIZE / 1048576}")
230+
echo "sdist size: ${SIZE_MB} MB"
231+
if [ "$SIZE" -gt $((MAX_SIZE_MB * 1048576)) ]; then
232+
echo "::error::sdist is ${SIZE_MB} MB, exceeding the ${MAX_SIZE_MB} MB limit"
233+
exit 1
234+
fi
235+
220236
- name: Build, inspect, and display contents of distributions
221237
shell: bash
222238
run: |

.github/workflows/update-hugo.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
with:
2121
persist-credentials: false
22+
submodules: recursive
2223
- name: Check for new Hugo release, and apply updates
2324
id: check-hugo-release
2425
env:
@@ -60,7 +61,13 @@ jobs:
6061
fi
6162
6263
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" setup.py
63-
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" hugo/cli.py
64+
sed -i "s/HUGO_VERSION = \"$CURRENT_VERSION\"/HUGO_VERSION = \"$LATEST_VERSION\"/" src/hugo/cli.py
65+
66+
# Update the Hugo submodule to the new version tag
67+
cd hugo
68+
git fetch origin tag "v$LATEST_VERSION" --no-tags
69+
git checkout "v$LATEST_VERSION"
70+
cd ..
6471
6572
echo "updated=true" >> "$GITHUB_OUTPUT"
6673
echo "latest_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ go.work
174174
.DS_Store
175175

176176
# Binaries
177-
hugo/binaries/*
177+
src/hugo/binaries/*
178178

179179
# ruff cache
180180
.ruff_cache/
181181

182182
# Hugo builder cache
183183
hugo_cache/
184+
185+
# Generated stamp file for sdist builds
186+
hugo/.hugo_commit_date

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "hugo"]
2+
path = hugo
3+
url = https://github.com/gohugoio/hugo.git

MANIFEST.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
graft src/hugo
12
graft hugo
23

34
include LICENSE LICENSE-hugo.txt README.md CODE_OF_CONDUCT.md SECURITY.md pyproject.toml setup.py setup.cfg
4-
exclude hugo/binaries/hugo-*
5+
exclude src/hugo/binaries/hugo-*
56

6-
global-exclude __pycache__ *.py[cod] *.so *.dylib .DS_Store .venv
7+
# Exclude some files from the Hugo submodule that are too large that they
8+
# inflate the sdist. They are not needed for building.
9+
prune hugo/docs
10+
prune hugo/testscripts
11+
recursive-exclude hugo testdata/*
12+
13+
global-exclude __pycache__ *.py[cod] *.so *.dylib .DS_Store .venv .git

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ Windows users can use the [Chocolatey package manager](https://chocolatey.org/)
163163
choco install mingw
164164
```
165165

166-
Then, clone the repository and run the build script:
166+
Then, clone the repository (with submodules) and run the build script:
167167

168168
```bash
169-
git clone https://github.com/agriyakhetarpal/hugo-python-distributions@main
169+
git clone --recurse-submodules https://github.com/agriyakhetarpal/hugo-python-distributions@main
170170
python -m venv venv
171171
source venv/bin/activate # on Unix-based systems
172172
venv\Scripts\activate.bat # on Windows

hugo

Submodule hugo added at d8c0dfc

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ Issues = "https://github.com/agriyakhetarpal/hugo-python-distributions/issues"
5151
Changelog = "https://github.com/agriyakhetarpal/hugo-python-distributions/releases"
5252

5353
[tool.setuptools.packages.find]
54+
where = ["src"]
5455
include = ["hugo", "hugo.*"]
5556

5657
[project.scripts]
5758
hugo = "hugo.cli:__call"
5859

5960
[tool.ruff]
60-
src = ["hugo"]
61+
src = ["src"]
6162
lint.extend-select = [
6263
"B", # flake8-bugbear
6364
"I", # isort

0 commit comments

Comments
 (0)