Skip to content

Commit 94a1b70

Browse files
authored
Merge pull request #7 from LedFx/build/cibuildwheels
Refactor CI workflow to use cibuildwheels
2 parents 72147cb + bc8c757 commit 94a1b70

4 files changed

Lines changed: 88 additions & 58 deletions

File tree

.github/workflows/pythonpackage.yml

Lines changed: 76 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,75 @@ name: samplerate
33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
78
runs-on: ${{ matrix.os }}
89
strategy:
910
fail-fast: false
10-
max-parallel: 12
1111
matrix:
12-
os: [ubuntu-latest, macos-latest, windows-latest]
13-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
12+
include:
13+
# Linux x86_64
14+
- os: ubuntu-latest
15+
arch: x86_64
16+
cibw_archs: "x86_64"
17+
# Linux ARM64 (native, no QEMU)
18+
- os: ubuntu-24.04-arm
19+
arch: aarch64
20+
cibw_archs: "aarch64"
21+
# Windows AMD64
22+
- os: windows-latest
23+
arch: AMD64
24+
cibw_archs: "AMD64"
25+
# macOS x86_64 (Intel)
26+
- os: macos-15-intel
27+
macoosx_deployment_target: "10.15"
28+
arch: x86_64
29+
cibw_archs: "x86_64"
30+
# macOS ARM64 (Apple Silicon)
31+
- os: macos-latest
32+
macoosx_deployment_target: "11.0"
33+
arch: arm64
34+
cibw_archs: "arm64"
1435
steps:
15-
- uses: actions/checkout@v5
16-
with:
17-
submodules: recursive
18-
# - name: Checkout submodules
19-
# shell: bash
20-
# run: |
21-
# auth_header="$(git config --local --get http.https://github.com/.extraheader)"
22-
# git submodule sync --recursive
23-
# git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
24-
- name: Install uv
25-
uses: astral-sh/setup-uv@v7
26-
- name: Sync dependencies with uv
27-
run: |
28-
uv sync --locked --all-groups --python ${{ matrix.python-version }}
29-
- name: Build sdist
30-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14'
31-
run: |
32-
uv build --sdist
33-
- name: Upload sdist
34-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14'
35-
uses: actions/upload-artifact@v5
36-
with:
37-
name: dist-python-samplerate-ledfx
38-
path: dist/*.tar.gz
39-
if-no-files-found: error
40-
- name: Build wheel for ${{ matrix.os }} Python ${{ matrix.python-version }}
41-
run: |
42-
uv build --wheel
43-
- name: Test with pytest
44-
run: |
45-
uv run pytest
36+
- uses: actions/checkout@v5
37+
with:
38+
submodules: recursive
4639

47-
- name: Upload wheel
48-
uses: actions/upload-artifact@v5
49-
with:
50-
name: dist-python-samplerate-ledfx-${{ matrix.os }}-py${{ matrix.python-version }}
51-
path: dist/*.whl
52-
if-no-files-found: error
40+
- name: Build wheels
41+
uses: pypa/cibuildwheel@v3.3.0
42+
env:
43+
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*
44+
CIBW_SKIP: "*-musllinux_*"
45+
with:
46+
extras: uv
47+
48+
- uses: actions/upload-artifact@v5
49+
with:
50+
name: cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}
51+
path: ./wheelhouse/*.whl
52+
53+
build_sdist:
54+
name: Build source distribution
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v5
58+
with:
59+
submodules: recursive
60+
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v7
63+
64+
- name: Build sdist
65+
run: uv build --sdist
66+
67+
- uses: actions/upload-artifact@v5
68+
with:
69+
name: cibw-sdist
70+
path: dist/*.tar.gz
71+
if-no-files-found: error
5372

5473
publish:
55-
needs: build
74+
needs: [build_wheels, build_sdist]
5675
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
5776
runs-on: ubuntu-latest
5877
environment:
@@ -61,16 +80,18 @@ jobs:
6180
permissions:
6281
id-token: write # Required for trusted publishing
6382
steps:
64-
- name: Install uv
65-
uses: astral-sh/setup-uv@v7
66-
- name: Download all artifacts
67-
uses: actions/download-artifact@v5
68-
with:
69-
path: dist
70-
pattern: dist-*
71-
merge-multiple: true
72-
- name: Display structure of downloaded files
73-
run: ls -R dist
74-
- name: Publish to PyPI
75-
run: |
76-
uv publish --trusted-publishing always
83+
- name: Install uv
84+
uses: astral-sh/setup-uv@v7
85+
86+
- name: Download all artifacts
87+
uses: actions/download-artifact@v5
88+
with:
89+
path: dist
90+
pattern: cibw-*
91+
merge-multiple: true
92+
93+
- name: Display structure of downloaded files
94+
run: ls -R dist
95+
96+
- name: Publish to PyPI
97+
run: uv publish --trusted-publishing always

external/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ FetchContent_MakeAvailable(pybind11)
1111

1212
# libsamplerate
1313
set(BUILD_TESTING OFF CACHE BOOL "Disable libsamplerate test build")
14+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1415

1516
FetchContent_Declare(
1617
libsamplerate

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = [
3030
]
3131

3232
[dependency-groups]
33-
dev = [
33+
test = [
3434
"pytest",
3535
"pytest-asyncio",
3636
"uvloop>=0.16.0; sys_platform != \"win32\"",
@@ -41,3 +41,11 @@ dev = [
4141
readme = {file = ["README.rst"]}
4242

4343
[tool.setuptools_scm]
44+
45+
[tool.cibuildwheel]
46+
test-groups = ["test"]
47+
test-command = "pytest {project}/tests"
48+
build-frontend = "build[uv]"
49+
build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*","cp314-*"]
50+
# Skip 32-bit builds and musllinux wheels
51+
skip = ["*-win32", "*-manylinux_i686", "*-musllinux*"]

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)