Skip to content

Commit a6c2cb1

Browse files
Ensure wheel isn't restricted to specific interpreter version (#556)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8305869 commit a6c2cb1

18 files changed

+288
-94
lines changed

.github/workflows/build-rtc.yml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,13 @@ jobs:
7979
with:
8080
submodules: true
8181

82-
- uses: actions/setup-python@v4
83-
84-
- name: Install cibuildwheel
85-
if: runner.os != 'macOS'
86-
run: python3 -m pip install cibuildwheel==2.17.0
87-
88-
- name: Install cibuildwheel on macOS
89-
if: runner.os == 'macOS'
90-
run: python3 -m pip install --break-system-packages cibuildwheel==2.17.0
82+
- uses: actions/setup-python@v5
83+
id: setup-python
84+
with:
85+
python-version: "3.11"
9186

9287
- name: Build wheels
93-
run: python3 -m cibuildwheel --output-dir dist
88+
run: pipx run --python '${{ steps.setup-python.outputs.python-path }}' cibuildwheel==3.3.1 --output-dir dist
9489
env:
9590
CIBW_ARCHS: ${{ matrix.archs }}
9691

@@ -120,9 +115,57 @@ jobs:
120115
name: rtc-release-sdist
121116
path: livekit-rtc/dist/*.tar.gz
122117

118+
119+
test:
120+
name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
121+
needs: [build_wheels]
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
include:
126+
# Linux x86_64 tests
127+
- os: ubuntu-latest
128+
python-version: "3.9"
129+
artifact: rtc-release-ubuntu-latest
130+
- os: ubuntu-latest
131+
python-version: "3.10"
132+
artifact: rtc-release-ubuntu-latest
133+
- os: ubuntu-latest
134+
python-version: "3.11"
135+
artifact: rtc-release-ubuntu-latest
136+
- os: ubuntu-latest
137+
python-version: "3.12"
138+
artifact: rtc-release-ubuntu-latest
139+
- os: ubuntu-latest
140+
python-version: "3.13"
141+
artifact: rtc-release-ubuntu-latest
142+
# macOS tests (arm64 runner)
143+
- os: macos-latest
144+
python-version: "3.9"
145+
artifact: rtc-release-macos-latest
146+
- os: macos-latest
147+
python-version: "3.12"
148+
artifact: rtc-release-macos-latest
149+
# Windows tests
150+
- os: windows-latest
151+
python-version: "3.9"
152+
artifact: rtc-release-windows-latest
153+
- os: windows-latest
154+
python-version: "3.12"
155+
artifact: rtc-release-windows-latest
156+
uses: ./.github/workflows/tests.yml
157+
with:
158+
os: ${{ matrix.os }}
159+
python-version: ${{ matrix.python-version }}
160+
artifact-name: ${{ matrix.artifact }}
161+
secrets:
162+
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
163+
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
164+
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
165+
123166
publish:
124167
name: Publish RTC release
125-
needs: [build_wheels, make_sdist]
168+
needs: [build_wheels, make_sdist, test]
126169
runs-on: ubuntu-latest
127170
permissions:
128171
id-token: write

.github/workflows/tests.yml

Lines changed: 116 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,140 @@
11
name: Tests
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
os:
7+
description: "Runner OS (e.g., ubuntu-latest, macos-latest, windows-latest)"
8+
required: true
9+
type: string
10+
python-version:
11+
description: "Python version to test"
12+
required: true
13+
type: string
14+
artifact-name:
15+
description: "Name of the wheel artifact to download"
16+
required: true
17+
type: string
18+
run-id:
19+
description: "Workflow run ID to download artifacts from (optional, uses current run if not specified)"
20+
required: false
21+
type: string
22+
secrets:
23+
LIVEKIT_URL:
24+
required: true
25+
LIVEKIT_API_KEY:
26+
required: true
27+
LIVEKIT_API_SECRET:
28+
required: true
1129

1230
jobs:
13-
tests:
14-
name: Run tests
15-
runs-on: ubuntu-latest
31+
test:
32+
name: Test (${{ inputs.os }}, Python ${{ inputs.python-version }})
33+
runs-on: ${{ inputs.os }}
1634
steps:
17-
- uses: actions/checkout@v6
35+
- uses: actions/checkout@v4
1836
with:
1937
submodules: true
2038
lfs: true
21-
- name: Install uv
2239

40+
- uses: actions/setup-python@v4
41+
with:
42+
python-version: ${{ inputs.python-version }}
43+
44+
- name: Install uv
2345
uses: astral-sh/setup-uv@v5
2446
with:
2547
enable-cache: true
2648
cache-dependency-glob: "uv.lock"
2749

28-
- name: Install the project
29-
run: uv sync --all-extras --dev
50+
- name: Download livekit-rtc wheel (current run)
51+
if: ${{ inputs.run-id == '' }}
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: ${{ inputs.artifact-name }}
55+
path: rtc-wheel
3056

31-
- uses: actions/setup-python@v6
57+
- name: Download livekit-rtc wheel (from specific run)
58+
if: ${{ inputs.run-id != '' }}
59+
uses: actions/download-artifact@v4
3260
with:
33-
python-version: '3.13'
61+
name: ${{ inputs.artifact-name }}
62+
path: rtc-wheel
63+
run-id: ${{ inputs.run-id }}
64+
github-token: ${{ github.token }}
65+
66+
- name: Select compatible wheel (macOS)
67+
if: runner.os == 'macOS'
68+
id: select-wheel-macos
69+
run: |
70+
# macOS artifacts contain both x86_64 and arm64 wheels, select the right one
71+
WHEEL=$(python3 -c "
72+
import glob
73+
import platform
74+
import sys
75+
76+
wheels = glob.glob('rtc-wheel/*.whl')
77+
machine = platform.machine().lower()
78+
79+
arch_map = {
80+
'x86_64': ['x86_64'],
81+
'arm64': ['arm64'],
82+
}
83+
patterns = arch_map.get(machine, [machine])
84+
85+
for wheel in wheels:
86+
wheel_lower = wheel.lower()
87+
if any(p in wheel_lower for p in patterns):
88+
print(wheel)
89+
sys.exit(0)
90+
91+
print(f'No matching wheel found for {machine}', file=sys.stderr)
92+
sys.exit(1)
93+
")
94+
echo "wheel=$WHEEL" >> $GITHUB_OUTPUT
3495
35-
- name: Run tests
96+
- name: Create venv and install dependencies (Unix)
97+
if: runner.os == 'Linux'
98+
run: |
99+
uv venv .test-venv
100+
source .test-venv/bin/activate
101+
uv pip install rtc-wheel/*.whl ./livekit-api ./livekit-protocol
102+
uv pip install pytest pytest-asyncio numpy matplotlib
103+
104+
- name: Create venv and install dependencies (macOS)
105+
if: runner.os == 'macOS'
106+
run: |
107+
uv venv .test-venv
108+
source .test-venv/bin/activate
109+
uv pip install "${{ steps.select-wheel-macos.outputs.wheel }}"
110+
uv pip install ./livekit-api ./livekit-protocol
111+
uv pip install pytest pytest-asyncio numpy matplotlib
112+
113+
- name: Create venv and install dependencies (Windows)
114+
if: runner.os == 'Windows'
115+
run: |
116+
uv venv .test-venv
117+
$wheel = (Get-ChildItem rtc-wheel\*.whl)[0].FullName
118+
uv pip install --python .test-venv $wheel .\livekit-api .\livekit-protocol
119+
uv pip install --python .test-venv pytest pytest-asyncio numpy matplotlib
120+
shell: pwsh
121+
122+
- name: Run tests (Unix)
123+
if: runner.os != 'Windows'
36124
env:
37125
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
38126
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
39127
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
40128
run: |
41-
42-
uv run python ./livekit-rtc/rust-sdks/download_ffi.py --output livekit-rtc/livekit/rtc/resources
43-
uv add ./livekit-rtc ./livekit-api ./livekit-protocol
44-
uv run pytest . --ignore=livekit-rtc/rust-sdks
129+
source .test-venv/bin/activate
130+
pytest tests/
131+
132+
- name: Run tests (Windows)
133+
if: runner.os == 'Windows'
134+
env:
135+
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
136+
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
137+
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
138+
run: .test-venv\Scripts\python.exe -m pytest tests/
139+
shell: pwsh
45140

livekit-rtc/hatch_build.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

livekit-rtc/pyproject.toml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[build-system]
2-
requires = ["hatchling", "requests"]
3-
build-backend = "hatchling.build"
2+
requires = [
3+
"setuptools>=61",
4+
"wheel",
5+
"requests",
6+
]
7+
build-backend = "setuptools.build_meta"
48

59
[project]
610
name = "livekit"
@@ -35,34 +39,34 @@ Documentation = "https://docs.livekit.io"
3539
Website = "https://livekit.io/"
3640
Source = "https://github.com/livekit/python-sdks/"
3741

38-
[tool.hatch.version]
39-
path = "livekit/rtc/version.py"
40-
41-
[tool.hatch.build.targets.wheel]
42-
packages = ["livekit"]
43-
artifacts = [
44-
"livekit/rtc/resources/*.so",
45-
"livekit/rtc/resources/*.dylib",
46-
"livekit/rtc/resources/*.dll",
47-
]
42+
[tool.setuptools.dynamic]
43+
version = { attr = "livekit.rtc.version.__version__" }
4844

49-
[tool.hatch.build.targets.wheel.hooks.custom]
50-
path = "hatch_build.py"
45+
[tool.setuptools.packages.find]
46+
include = ["livekit.*"]
5147

52-
[tool.hatch.build.targets.sdist]
53-
include = ["/livekit", "/rust-sdks"]
48+
[tool.setuptools.package-data]
49+
"livekit.rtc" = ["_proto/*.py", "py.typed", "*.pyi", "**/*.pyi"]
50+
"livekit.rtc.resources" = [
51+
"*.so",
52+
"*.dylib",
53+
"*.dll",
54+
"LICENSE.md",
55+
"*.h",
56+
"jupyter-html/index.html",
57+
]
5458

5559
[tool.cibuildwheel]
5660
build = "cp39-*"
57-
skip = "*-musllinux_*" # not supported (libwebrtc is using glibc)
58-
61+
skip = "*-musllinux_*" # not supported (libwebrtc requires glibc)
5962
before-build = "pip install requests && python rust-sdks/download_ffi.py --output livekit/rtc/resources"
6063

61-
manylinux-x86_64-image = "manylinux_2_28"
62-
manylinux-i686-image = "manylinux_2_28"
63-
manylinux-aarch64-image = "manylinux_2_28"
64-
manylinux-ppc64le-image = "manylinux_2_28"
65-
manylinux-s390x-image = "manylinux_2_28"
66-
manylinux-pypy_x86_64-image = "manylinux_2_28"
67-
manylinux-pypy_i686-image = "manylinux_2_28"
68-
manylinux-pypy_aarch64-image = "manylinux_2_28"
64+
# macOS deployment targets must match the FFI binaries (see rust-sdks/.github/workflows/ffi-builds.yml)
65+
# x86_64 supports macOS 10.15+, arm64 requires macOS 11.0+
66+
[[tool.cibuildwheel.overrides]]
67+
select = "*macosx_x86_64"
68+
environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }
69+
70+
[[tool.cibuildwheel.overrides]]
71+
select = "*macosx_arm64"
72+
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }

0 commit comments

Comments
 (0)