Skip to content

Commit b7e1b21

Browse files
committed
Refactor CI workflow to support manylinux wheels
1 parent 6d68220 commit b7e1b21

2 files changed

Lines changed: 116 additions & 54 deletions

File tree

.github/workflows/pythonpackage.yml

Lines changed: 113 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,136 @@
11
name: samplerate
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [master]
6+
tags: ["v*", "test-*"]
7+
pull_request:
8+
types: [opened, synchronize, reopened, labeled]
9+
workflow_dispatch:
410

511
jobs:
6-
build:
12+
build_sdist:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
with:
17+
submodules: recursive
18+
fetch-depth: 0
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: "3.9"
23+
- name: Build sdist
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -U setuptools setuptools_scm build twine
27+
python -m build --sdist
28+
twine check dist/*
29+
- uses: actions/upload-artifact@v6
30+
with:
31+
name: sdist
32+
path: dist/*.tar.gz
33+
34+
build_wheels_pr:
35+
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-build')
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
include:
41+
- os: ubuntu-latest
42+
cibw_build: "cp314-manylinux_x86_64"
43+
cibw_archs: "x86_64"
44+
- os: macos-latest
45+
cibw_build: "cp314-macosx_universal2"
46+
cibw_archs: "universal2"
47+
- os: windows-latest
48+
cibw_build: "cp314-win_amd64"
49+
cibw_archs: "AMD64"
50+
steps:
51+
- uses: actions/checkout@v6
52+
with:
53+
submodules: recursive
54+
fetch-depth: 0
55+
- uses: pypa/cibuildwheel@v3.4.0
56+
env:
57+
CIBW_BUILD: ${{ matrix.cibw_build }}
58+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
59+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
60+
CIBW_TEST_REQUIRES: "pytest numpy"
61+
CIBW_TEST_COMMAND: "pytest {project}/tests"
762

63+
build_wheels:
64+
if: >-
65+
github.event_name == 'push' ||
66+
github.event_name == 'workflow_dispatch' ||
67+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'full-build'))
868
runs-on: ${{ matrix.os }}
969
strategy:
1070
fail-fast: false
11-
max-parallel: 12
1271
matrix:
1372
os: [ubuntu-latest, macos-latest, windows-latest]
14-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
1573
steps:
16-
- uses: actions/checkout@v3
17-
- name: Checkout submodules
18-
shell: bash
19-
run: |
20-
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
21-
git submodule sync --recursive
22-
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
74+
- uses: actions/checkout@v6
2575
with:
26-
python-version: ${{ matrix.python-version }}
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install -U setuptools setuptools_scm wheel build twine
31-
pip install -r requirements.txt
32-
- name: Build package
33-
run: |
34-
python -m pip install -e .
35-
- name: Test with pytest
36-
run: |
37-
pytest
38-
- name: Test the universal wheels
39-
if: matrix.os == 'ubuntu-latest'
40-
run: |
41-
# do not build binary wheels on linux
42-
python -m build --sdist
43-
twine check dist/*
44-
- name: Test the binary wheels
45-
if: matrix.os != 'ubuntu-latest'
46-
run: |
47-
python -m build
48-
twine check dist/*
49-
- name: Publish sdist to pypi
50-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
76+
submodules: recursive
77+
fetch-depth: 0
78+
- name: Set up QEMU
79+
if: runner.os == 'Linux'
80+
uses: docker/setup-qemu-action@v3
81+
with:
82+
platforms: all
83+
- uses: pypa/cibuildwheel@v3.4.0
5184
env:
52-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
53-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
85+
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*"
86+
CIBW_SKIP: "cp39-*aarch64 cp310-*aarch64 cp311-*aarch64 cp312-*aarch64 cp313-*aarch64"
87+
CIBW_ARCHS_LINUX: "x86_64 aarch64"
88+
CIBW_ARCHS_MACOS: "universal2"
89+
CIBW_ARCHS_WINDOWS: "AMD64"
90+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
91+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
92+
CIBW_TEST_REQUIRES: "pytest numpy"
93+
CIBW_TEST_COMMAND: "pytest {project}/tests"
94+
CIBW_TEST_SKIP: "cp314-*"
95+
- uses: actions/upload-artifact@v6
96+
with:
97+
name: wheels-${{ matrix.os }}
98+
path: wheelhouse/*.whl
99+
100+
publish:
101+
needs: [build_sdist, build_wheels]
102+
runs-on: ubuntu-latest
103+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
104+
steps:
105+
- uses: actions/download-artifact@v8
106+
with:
107+
path: dist
108+
merge-multiple: true
109+
- name: Validate wheels
54110
run: |
55-
twine upload --skip-existing dist/*
56-
- name: Publish bdist to pypi
57-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && matrix.os != 'ubuntu-latest'
111+
pip install twine
112+
twine check dist/*
113+
- name: Publish to PyPI
58114
env:
59115
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
60116
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
61117
run: |
62118
twine upload --skip-existing dist/*
63-
- name: Publish sdist to pypi-test
64-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-') && matrix.os == 'ubuntu-latest'
65-
env:
66-
TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }}
67-
TWINE_PASSWORD: ${{ secrets.PYPITEST_PASSWORD }}
68-
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
119+
120+
publish-test:
121+
needs: [build_sdist, build_wheels]
122+
runs-on: ubuntu-latest
123+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-')
124+
steps:
125+
- uses: actions/download-artifact@v8
126+
with:
127+
path: dist
128+
merge-multiple: true
129+
- name: Validate wheels
69130
run: |
70-
twine upload --skip-existing dist/*
71-
- name: Publish bdist to pypi-test
72-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-') && matrix.os != 'ubuntu-latest'
131+
pip install twine
132+
twine check dist/*
133+
- name: Publish to PyPI Test
73134
env:
74135
TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }}
75136
TWINE_PASSWORD: ${{ secrets.PYPITEST_PASSWORD }}

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ Installation
4141

4242
$ pip install samplerate
4343

44-
Binary wheels of `libsamplerate`_ for macOS and Windows (64 bit) are available.
45-
For other systems, a C++ 14 or above compiler is required to build the package.
44+
Binary wheels of `libsamplerate`_ are available for macOS (x86_64, arm64), Linux
45+
(x86_64, aarch64), and Windows (x86_64). Building from source on other platforms
46+
requires a C++14 or later compiler.
4647

4748

4849
Usage

0 commit comments

Comments
 (0)