Skip to content

Commit d965cca

Browse files
authored
Switch to emake for build system (#29)
* Switch to emake for build system * Better name for test matrix * Review feedback * Download test images before testing wheels * Fix testing on mac and windows * Force bash for testing * Force bash use * Use emake for requirements * Don't install requirements twice
1 parent 677ec27 commit d965cca

6 files changed

Lines changed: 76 additions & 259 deletions

File tree

‎.github/workflows/build.yaml‎

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
pull_request:
77
workflow_dispatch:
88
release:
9-
types: [ released ]
9+
types: [released]
1010
permissions: read-all
1111
jobs:
1212
lint:
13-
name: Lint code
13+
name: Lint codebase
1414
runs-on: ubuntu-latest
1515
strategy:
1616
fail-fast: false
@@ -23,14 +23,16 @@ jobs:
2323
steps:
2424
- name: Checkout the Git repository
2525
uses: actions/checkout@v6
26-
- name: Setup Python
27-
uses: actions/setup-python@v6
26+
- uses: actions/setup-python@v6
2827
with:
2928
python-version: ${{ matrix.python }}
30-
cache: "pip"
31-
- name: Lint code
32-
shell: bash
33-
run: make lint format
29+
cache: pip
30+
- &install-emake
31+
name: Install emake
32+
run: pip install emake
33+
- name: Run lint
34+
run: emake lint
35+
3436
test-image:
3537
name: Generate test ext4 image
3638
runs-on: ubuntu-latest
@@ -57,10 +59,11 @@ jobs:
5759
test64.ext4.tmp
5860
test_htree.ext4
5961
if-no-files-found: error
62+
6063
test:
61-
name: Test on ${{ matrix.os }} python ${{ matrix.python }}
64+
name: Test
6265
runs-on: ${{ matrix.os }}
63-
needs: [ test-image ]
66+
needs: test-image
6467
strategy:
6568
fail-fast: false
6669
matrix:
@@ -72,19 +75,20 @@ jobs:
7275
steps:
7376
- name: Checkout the Git repository
7477
uses: actions/checkout@v6
78+
- uses: actions/setup-python@v6
79+
with:
80+
python-version: ${{ matrix.python }}
81+
cache: pip
82+
- *install-emake
7583
- name: Download test.ext4
7684
uses: actions/download-artifact@v8
7785
with:
7886
name: test.ext4
7987
path: .
80-
- name: Setup Python
81-
uses: actions/setup-python@v6
82-
with:
83-
python-version: ${{ matrix.python }}
84-
cache: "pip"
85-
- name: Run test
88+
- name: Run tests
8689
shell: bash
87-
run: make test
90+
run: emake test
91+
8892
fuzz:
8993
name: Fuzz
9094
runs-on: ubuntu-latest
@@ -104,55 +108,55 @@ jobs:
104108
with:
105109
python-version: ${{ matrix.python }}
106110
cache: "pip"
111+
- *install-emake
107112
- name: Run test
108113
shell: bash
109114
run: make fuzz
115+
110116
build-sdist:
111-
name: Build pip package
117+
name: Build sdist
118+
needs: &build-needs
119+
- lint
120+
- test
112121
runs-on: ubuntu-latest
113-
needs: [ test, lint ]
114122
steps:
115123
- name: Checkout the Git repository
116124
uses: actions/checkout@v6
117-
- name: Setup Python
118-
uses: actions/setup-python@v6
119-
with:
120-
python-version: "3.11"
121-
cache: "pip"
122-
- name: Install build tool
123-
run: pip install build
124-
- name: Building package
125-
run: make release
125+
- *install-emake
126+
- name: Building sdist
127+
run: emake build --sdist
126128
- uses: actions/upload-artifact@v6
127129
with:
128130
name: pip-sdist
129131
path: dist/*
130132
if-no-files-found: error
133+
131134
build-any-wheel:
132135
name: Build wheel
136+
needs: *build-needs
133137
runs-on: ubuntu-latest
134-
needs: [ test, lint ]
135138
steps:
136139
- name: Checkout the Git repository
137140
uses: actions/checkout@v6
138-
- name: Setup Python
139-
uses: actions/setup-python@v6
141+
- *install-emake
142+
- name: Building wheel
143+
run: emake build --wheel
144+
- name: Download test.ext4
145+
uses: actions/download-artifact@v8
140146
with:
141-
python-version: "3.11"
142-
cache: "pip"
143-
- name: Install build tool
144-
run: pip install build
145-
- name: Building package
146-
run: make wheel
147+
name: test.ext4
148+
path: .
149+
- name: Test wheel
150+
run: emake test --wheel
147151
- uses: actions/upload-artifact@v6
148152
with:
149153
name: pip-wheel-none-any
150154
path: dist/*
151155
if-no-files-found: error
156+
152157
build-wheel:
153158
name: Build wheel
154-
# if: github.repository == 'Eeems/python-ext4' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
155-
needs: [ lint, test, test-image ]
159+
needs: *build-needs
156160
runs-on: ubuntu-latest
157161
strategy:
158162
fail-fast: false
@@ -169,43 +173,49 @@ jobs:
169173
libc:
170174
- glibc
171175
- musl
176+
exclude:
177+
- arch: i686 # segfaults currently
178+
python: "3.14"
179+
libc: glibc
172180
steps:
173181
- name: Checkout the Git repository
174182
uses: actions/checkout@v6
183+
- *install-emake
175184
- name: Building wheel
176-
run: ./wheel.sh
177-
env:
178-
python: ${{ matrix.python }}
179-
arch: ${{ matrix.arch }}
180-
libc: ${{ matrix.libc }}
185+
run: |
186+
emake build \
187+
--native-wheel \
188+
--arch ${{ matrix.arch }} \
189+
--libc ${{ matrix.libc }} \
190+
--python ${{ matrix.python }}
181191
- name: Download test.ext4
182192
uses: actions/download-artifact@v8
183193
with:
184194
name: test.ext4
185195
path: .
186196
- name: Testing wheel
187-
run: ./test-wheel.sh
188-
env:
189-
python: ${{ matrix.python }}
190-
arch: ${{ matrix.arch }}
191-
libc: ${{ matrix.libc }}
197+
run: |
198+
emake test \
199+
--wheel \
200+
--arch ${{ matrix.arch }} \
201+
--libc ${{ matrix.libc }} \
202+
--python ${{ matrix.python }}
192203
- uses: actions/upload-artifact@v6
193204
with:
194205
name: pip-wheel-${{ matrix.python }}-${{ matrix.arch }}-${{ matrix.libc }}
195-
path: wheelhouse/*
206+
path: dist/*
196207
if-no-files-found: error
208+
197209
publish:
198210
name: Publish to PyPi
199211
if: github.repository == 'Eeems/python-ext4' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
200212
needs: &release-needs
201213
- build-sdist
202214
- build-any-wheel
203215
- build-wheel
204-
- fuzz
205216
runs-on: ubuntu-latest
206217
permissions:
207218
id-token: write
208-
contents: write
209219
environment:
210220
name: pypi
211221
url: https://pypi.org/p/ext4
@@ -216,17 +226,15 @@ jobs:
216226
with:
217227
pattern: pip-*
218228
merge-multiple: true
219-
path: artifacts
229+
path: dist
220230
- name: Publish package distributions to PyPI
221231
uses: pypa/gh-action-pypi-publish@release/v1
222232
with:
223233
packages-dir: ${{ steps.download.outputs.download-path }}
224234
skip-existing: true
225-
print-hash: "false"
226-
print_hash: "false"
227-
verbose: "false"
235+
228236
release:
229-
name: Add pip to release
237+
name: Add release artifacts
230238
if: github.repository == 'Eeems/python-ext4' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
231239
needs: *release-needs
232240
runs-on: ubuntu-latest
@@ -235,19 +243,13 @@ jobs:
235243
steps:
236244
- name: Checkout the Git repository
237245
uses: actions/checkout@v6
238-
- name: Download pip packages
246+
- name: Download artifact
239247
id: download
240248
uses: actions/download-artifact@v8
241249
with:
242250
pattern: pip-*
243251
merge-multiple: true
244-
path: artifacts
245-
- name: Download pip packages
246-
uses: actions/download-artifact@v8
247-
with:
248-
pattern: test.ext4
249-
merge-multiple: true
250-
path: artifacts
252+
path: dist
251253
- name: Upload to release
252254
run: find . -type f | xargs -rI {} gh release upload "$TAG" {} --clobber
253255
env:

‎Makefile‎

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,8 @@ endif
2626
clean:
2727
git clean --force -dX
2828

29-
.PHONY: build
30-
build: wheel
31-
32-
.PHONY: release
33-
release: wheel sdist
34-
35-
.PHONY: sdist
36-
sdist: dist/${PACKAGE}-${VERSION}.tar.gz
37-
38-
.PHONY: wheel
39-
wheel: dist/${PACKAGE}-${VERSION}-py3-none-any.whl
40-
41-
.PHONY: native-wheel
42-
native-wheel:${VENV_BIN_ACTIVATE} dist $(OBJ)
43-
. ${VENV_BIN_ACTIVATE}; \
44-
python -m build --wheel
45-
46-
dist:
47-
mkdir -p dist
48-
49-
dist/${PACKAGE}-${VERSION}.tar.gz: ${VENV_BIN_ACTIVATE} dist $(OBJ)
50-
. ${VENV_BIN_ACTIVATE}; \
51-
python -m build --sdist
52-
53-
dist/${PACKAGE}-${VERSION}-py3-none-any.whl: ${VENV_BIN_ACTIVATE} dist $(OBJ)
54-
. ${VENV_BIN_ACTIVATE}; \
55-
python -m build --wheel --config-setting=build_with_nuitka=false
56-
5729
${VENV_BIN_ACTIVATE}: pyproject.toml
58-
@echo "Setting up development virtual env in .venv"
59-
python -m venv .venv
60-
. ${VENV_BIN_ACTIVATE}; \
61-
python -m pip install \
62-
--require-virtualenv \
63-
--editable \
64-
.[dev];
65-
66-
.PHONY: test
67-
test: ${VENV_BIN_ACTIVATE}
68-
@. ${VENV_BIN_ACTIVATE}; \
69-
python -m pip install \
70-
--require-virtualenv \
71-
--editable \
72-
.[test];
73-
$(SHELL) test.sh
30+
emake requirements dev
7431

7532
.PHONY: fuzz
7633
fuzz: ${VENV_BIN_ACTIVATE}
@@ -83,46 +40,3 @@ fuzz: ${VENV_BIN_ACTIVATE}
8340
python fuzz.py \
8441
-rss_limit_mb=2048 \
8542
-max_total_time=$(FUZZ_TIMEOUT)
86-
87-
.PHONY: all
88-
all: release
89-
90-
.PHONY: lint
91-
lint: $(VENV_BIN_ACTIVATE);
92-
@. ${VENV_BIN_ACTIVATE}; \
93-
python -m pip install \
94-
--require-virtualenv \
95-
--editable \
96-
.[test]; \
97-
python -m pip install \
98-
--require-virtualenv \
99-
--editable \
100-
.[fuzz]
101-
. $(VENV_BIN_ACTIVATE); \
102-
python -m ruff check; \
103-
python -m basedpyright
104-
105-
.PHONY: lint-fix
106-
lint-fix: $(VENV_BIN_ACTIVATE); \
107-
@. ${VENV_BIN_ACTIVATE}; \
108-
python -m pip install \
109-
--require-virtualenv \
110-
--editable \
111-
.[test]; \
112-
python -m pip install \
113-
--require-virtualenv \
114-
--editable \
115-
.[fuzz]
116-
. $(VENV_BIN_ACTIVATE); \
117-
python -m ruff check --fix; \
118-
python -m basedpyright
119-
120-
.PHONY: format
121-
format: $(VENV_BIN_ACTIVATE)
122-
. $(VENV_BIN_ACTIVATE); \
123-
python -m ruff format --diff
124-
125-
.PHONY: format-fix
126-
format-fix: $(VENV_BIN_ACTIVATE)
127-
. $(VENV_BIN_ACTIVATE); \
128-
python -m ruff format

‎pyproject.toml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ classifiers = [
2222
"Topic :: System :: Filesystems",
2323
"Topic :: Utilities",
2424
]
25+
license = "MIT"
2526
dynamic = ["readme"]
2627
dependencies = [
2728
"cachetools==6.0.0",
@@ -37,9 +38,7 @@ dev = [
3738
'basedpyright',
3839
]
3940
test = []
40-
fuzz = [
41-
"atheris",
42-
]
41+
fuzz = ["atheris"]
4342

4443
[project.urls]
4544
Homepage = "https://github.com/Eeems/python-ext4"
@@ -89,3 +88,6 @@ ignore = [
8988
exclude = [".venv", "build"]
9089
reportMissingTypeStubs = false
9190
reportImportCycles = false
91+
92+
[tool.emake]
93+
test = ["bash ./test.sh"]

0 commit comments

Comments
 (0)