-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate wheel build script using cibuildwheel.
- Loading branch information
Showing
2 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: Wheel build | ||
|
||
on: | ||
release: | ||
types: [created] | ||
schedule: | ||
# ┌───────────── minute (0 - 59) | ||
# │ ┌───────────── hour (0 - 23) | ||
# │ │ ┌───────────── day of the month (1 - 31) | ||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | ||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | ||
# │ │ │ │ │ | ||
- cron: "42 3 * * 4" | ||
push: | ||
paths: | ||
- .github/workflows/wheels.yml | ||
- requirements.txt | ||
- pyproject.toml | ||
- MANIFEST.in | ||
- Makefile | ||
- setup.py | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- .github/workflows/wheels.yml | ||
- requirements.txt | ||
- pyproject.toml | ||
- MANIFEST.in | ||
- Makefile | ||
- setup.py | ||
workflow_dispatch: | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
sdist: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install Python dependencies | ||
run: python -m pip install -U pip setuptools wheel && python -m pip install -U -r requirements.txt | ||
|
||
- name: Build sdist | ||
run: make sdist | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: dist/*.tar.gz | ||
|
||
- name: Upload sdist | ||
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 | ||
with: | ||
name: sdist | ||
path: dist/*.tar.gz | ||
|
||
generate-wheels-matrix: | ||
# Create a matrix of all architectures & versions to build. | ||
# This enables the next step to run cibuildwheel in parallel. | ||
# From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210 | ||
name: Generate wheels matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
include: ${{ steps.set-matrix.outputs.include }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install cibuildwheel | ||
# Nb. keep cibuildwheel version pin consistent with job below | ||
run: pipx install cibuildwheel==2.16.2 | ||
- id: set-matrix | ||
run: | | ||
MATRIX=$( | ||
{ | ||
cibuildwheel --print-build-identifiers --platform linux \ | ||
| jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \ | ||
&& cibuildwheel --print-build-identifiers --platform macos \ | ||
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \ | ||
&& cibuildwheel --print-build-identifiers --platform windows \ | ||
| jq -nRc '{"only": inputs, "os": "windows-2019"}' | ||
} | jq -sc | ||
) | ||
echo "include=$MATRIX" >> $GITHUB_OUTPUT | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.only }} | ||
needs: generate-wheels-matrix | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
if: runner.os == 'Linux' | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: all | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
with: | ||
only: ${{ matrix.only }} | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
name: lxml-wheels | ||
|
||
upload_release_assets: | ||
name: Upload Release Assets | ||
needs: [ build_wheels ] | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags') | ||
|
||
steps: | ||
- name: Download bdist files | ||
id: download_artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: lxml-wheels | ||
path: ~/downloads | ||
|
||
- name: List downloaded artifacts | ||
run: ls -la ~/downloads | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: ~/downloads/*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[build-system] | ||
requires = ["Cython>=3.0.8", "setuptools", "wheel"] | ||
|
||
[tool.cibuildwheel] | ||
build-verbosity = 2 | ||
skip = ["pp*", "*-musllinux_i686"] | ||
# test-command = "python -m unittest {package}/test_fractions.py -p -v" | ||
|
||
[tool.cibuildwheel.linux] | ||
archs = ["x86_64", "aarch64", "i686"] | ||
repair-wheel-command = "auditwheel repair --strip -w {dest_dir} {wheel}" | ||
|
||
[tool.cibuildwheel.linux.environment] | ||
CFLAGS = "-O3 -g1 -pipe -fPIC -march=core2" | ||
AR = "gcc-ar" | ||
NM = "gcc-nm" | ||
RANLIB = "gcc-ranlib" | ||
|
||
[[tool.cibuildwheel.overrides]] | ||
select = "*aarch64" | ||
environment = {CFLAGS = "-O3 -g0 -pipe -fPIC -march=armv8-a -mtune=cortex-a72", AR = "gcc-ar", NM = "gcc-nm", RANLIB = "gcc-ranlib" } | ||
|
||
[tool.cibuildwheel.windows] | ||
archs = ["AMD64", "x86"] | ||
|
||
[tool.cibuildwheel.macos] | ||
# https://cibuildwheel.readthedocs.io/en/stable/faq/#what-to-provide suggests to provide | ||
# x86_64 and one of universal2 or arm64 wheels. x86_64 is still required by older pips, | ||
# so additional arm64 wheels would suffice. However, since the library build uses a mixed | ||
# amd64/arm64 setup, we build universal2 wheels regardless. | ||
archs = ["x86_64", "universal2"] |