Skip to content

Commit a28ce1a

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

2 files changed

Lines changed: 84 additions & 38 deletions

File tree

.github/workflows/pythonpackage.yml

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,118 @@ name: samplerate
33
on: [push, pull_request]
44

55
jobs:
6-
build:
7-
6+
test:
87
runs-on: ${{ matrix.os }}
98
strategy:
109
fail-fast: false
11-
max-parallel: 12
1210
matrix:
1311
os: [ubuntu-latest, macos-latest, windows-latest]
1412
python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
1513
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
14+
- uses: actions/checkout@v6
15+
with:
16+
submodules: recursive
2317
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v6
2519
with:
2620
python-version: ${{ matrix.python-version }}
2721
- name: Install dependencies
2822
run: |
2923
python -m pip install --upgrade pip
30-
pip install -U setuptools setuptools_scm wheel build twine
3124
pip install -r requirements.txt
3225
- name: Build package
3326
run: |
3427
python -m pip install -e .
3528
- name: Test with pytest
3629
run: |
3730
pytest
38-
- name: Test the universal wheels
39-
if: matrix.os == 'ubuntu-latest'
31+
32+
build_sdist:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v6
36+
with:
37+
submodules: recursive
38+
fetch-depth: 0
39+
- name: Set up Python
40+
uses: actions/setup-python@v6
41+
with:
42+
python-version: "3.12"
43+
- name: Build sdist
4044
run: |
41-
# do not build binary wheels on linux
45+
python -m pip install --upgrade pip
46+
pip install -U setuptools setuptools_scm build twine
4247
python -m build --sdist
4348
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'
49+
- uses: actions/upload-artifact@v6
50+
with:
51+
name: sdist
52+
path: dist/*.tar.gz
53+
54+
build_wheels:
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
os: [ubuntu-latest, macos-latest, windows-latest]
60+
steps:
61+
- uses: actions/checkout@v6
62+
with:
63+
submodules: recursive
64+
fetch-depth: 0
65+
- name: Set up QEMU
66+
if: runner.os == 'Linux'
67+
uses: docker/setup-qemu-action@v3
68+
with:
69+
platforms: all
70+
- uses: pypa/cibuildwheel@v3.4.0
5171
env:
52-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
53-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
72+
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*"
73+
CIBW_ARCHS_LINUX: "x86_64 aarch64"
74+
CIBW_ARCHS_WINDOWS: "AMD64"
75+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
76+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
77+
CIBW_TEST_REQUIRES: "pytest numpy"
78+
CIBW_TEST_COMMAND: "pytest {project}/tests"
79+
- uses: actions/upload-artifact@v6
80+
with:
81+
name: wheels-${{ matrix.os }}
82+
path: wheelhouse/*.whl
83+
84+
publish:
85+
needs: [test, build_sdist, build_wheels]
86+
runs-on: ubuntu-latest
87+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
88+
steps:
89+
- uses: actions/download-artifact@v8
90+
with:
91+
path: dist
92+
merge-multiple: true
93+
- name: Validate wheels
5494
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'
95+
pip install twine
96+
twine check dist/*
97+
- name: Publish to PyPI
5898
env:
5999
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
60100
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
61101
run: |
62102
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/
103+
104+
publish-test:
105+
needs: [test, build_sdist, build_wheels]
106+
runs-on: ubuntu-latest
107+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-')
108+
steps:
109+
- uses: actions/download-artifact@v8
110+
with:
111+
path: dist
112+
merge-multiple: true
113+
- name: Validate wheels
69114
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'
115+
pip install twine
116+
twine check dist/*
117+
- name: Publish to PyPI Test
73118
env:
74119
TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }}
75120
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)