Skip to content

Commit

Permalink
Experiment: use Python scripting for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
James-E-A committed Feb 16, 2024
1 parent bc46266 commit 957bb01
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/python_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: install dev requirements
run: python -m pip install -r requirements-dev.txt
run: python scripts/install-dev-reqs.py
- name: build sdist
run: python -m build --sdist && twine check ./dist/*
run: python scripts/build-sdist.py
- name: upload sdist
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -58,11 +58,6 @@ jobs:
with:
name: sdist
path: ./dist/
- uses: tj-actions/glob@v20
# FIXME? use a more programmatic or integrated solution here
id: sdist_glob
with:
files: ./dist/*

# Used to host cibuildwheel
- uses: actions/setup-python@v3
Expand All @@ -71,11 +66,11 @@ jobs:
uses: docker/setup-qemu-action@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.3
run: python scripts/_run-cibw.py install

- name: Build wheels
# https://github.com/pypa/cibuildwheel/issues/173#issuecomment-1501236916
run: python -m cibuildwheel ${{ steps.sdist_glob.outputs.paths }} --output-dir ./dist
run: python scripts/_run-cibw.py build dist/
env:
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_ARCHS: ${{ matrix.cibw_archs }}
Expand Down
5 changes: 3 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cffi >= 1.14.5
setuptools >= 49.5.0
wheel >= 0.30.0
# Beyond "build" requirements
wheel >= 0.28.0

# Beyond nominal "build" requirements
build >= 0.6.0
twine >= 1.15.0
24 changes: 24 additions & 0 deletions scripts/_run-cibw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
import os
from pathlib import Path
import subprocess
import sys

CIBW_VER = os.environ.get('_CIBW_VER', '2.16.3')

if sys.argv[1] == 'install':
subprocess.check_call([
sys.executable, '-m', 'pip',
'install', f'cibuildwheel == {CIBW_VER}'
])

elif sys.argv[1] == 'build':
target = Path(sys.argv[2])
subprocess.check_call([
sys.executable, '-m', 'cibuildwheel',
*target.glob('*'),
'--output-dir', target
])

else:
raise RuntimeError()
14 changes: 14 additions & 0 deletions scripts/build-sdist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
import sys

subprocess.check_call([
sys.executable, '-m', 'build',
'--sdist'
)]

subprocess.check_call([
sys.executable, '-m', 'twine',
'check', *Path('dist').glob('*')
])
10 changes: 10 additions & 0 deletions scripts/install-dev-reqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
import sys

subprocess.check_call([
sys.executable, '-m', 'pip',
'install',
'-r', Path(__file__).parent / '..' / 'requirements-dev.txt'
])

0 comments on commit 957bb01

Please sign in to comment.