Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 54 additions & 11 deletions .github/workflows/build-rtc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,13 @@
with:
submodules: true

- uses: actions/setup-python@v4

- name: Install cibuildwheel
if: runner.os != 'macOS'
run: python3 -m pip install cibuildwheel==2.17.0

- name: Install cibuildwheel on macOS
if: runner.os == 'macOS'
run: python3 -m pip install --break-system-packages cibuildwheel==2.17.0
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.11"

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

Expand Down Expand Up @@ -120,9 +115,57 @@
name: rtc-release-sdist
path: livekit-rtc/dist/*.tar.gz


test:
name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
needs: [build_wheels]
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 tests
- os: ubuntu-latest
python-version: "3.9"
artifact: rtc-release-ubuntu-latest
- os: ubuntu-latest
python-version: "3.10"
artifact: rtc-release-ubuntu-latest
- os: ubuntu-latest
python-version: "3.11"
artifact: rtc-release-ubuntu-latest
- os: ubuntu-latest
python-version: "3.12"
artifact: rtc-release-ubuntu-latest
- os: ubuntu-latest
python-version: "3.13"
artifact: rtc-release-ubuntu-latest
# macOS tests (arm64 runner)
- os: macos-latest
python-version: "3.9"
artifact: rtc-release-macos-latest
- os: macos-latest
python-version: "3.12"
artifact: rtc-release-macos-latest
# Windows tests
- os: windows-latest
python-version: "3.9"
artifact: rtc-release-windows-latest
- os: windows-latest
python-version: "3.12"
artifact: rtc-release-windows-latest
uses: ./.github/workflows/tests.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
artifact-name: ${{ matrix.artifact }}
secrets:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}

publish:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: Publish RTC release
needs: [build_wheels, make_sdist]
needs: [build_wheels, make_sdist, test]
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down
137 changes: 116 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,140 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
workflow_call:
inputs:
os:
description: "Runner OS (e.g., ubuntu-latest, macos-latest, windows-latest)"
required: true
type: string
python-version:
description: "Python version to test"
required: true
type: string
artifact-name:
description: "Name of the wheel artifact to download"
required: true
type: string
run-id:
description: "Workflow run ID to download artifacts from (optional, uses current run if not specified)"
required: false
type: string
secrets:
LIVEKIT_URL:
required: true
LIVEKIT_API_KEY:
required: true
LIVEKIT_API_SECRET:
required: true

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
test:
name: Test (${{ inputs.os }}, Python ${{ inputs.python-version }})
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
submodules: true
lfs: true
- name: Install uv

- uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install the project
run: uv sync --all-extras --dev
- name: Download livekit-rtc wheel (current run)
if: ${{ inputs.run-id == '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: rtc-wheel

- uses: actions/setup-python@v6
- name: Download livekit-rtc wheel (from specific run)
if: ${{ inputs.run-id != '' }}
uses: actions/download-artifact@v4
with:
python-version: '3.13'
name: ${{ inputs.artifact-name }}
path: rtc-wheel
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}

- name: Select compatible wheel (macOS)
if: runner.os == 'macOS'
id: select-wheel-macos
run: |
# macOS artifacts contain both x86_64 and arm64 wheels, select the right one
WHEEL=$(python3 -c "
import glob
import platform
import sys

wheels = glob.glob('rtc-wheel/*.whl')
machine = platform.machine().lower()

arch_map = {
'x86_64': ['x86_64'],
'arm64': ['arm64'],
}
patterns = arch_map.get(machine, [machine])

for wheel in wheels:
wheel_lower = wheel.lower()
if any(p in wheel_lower for p in patterns):
print(wheel)
sys.exit(0)

print(f'No matching wheel found for {machine}', file=sys.stderr)
sys.exit(1)
")
echo "wheel=$WHEEL" >> $GITHUB_OUTPUT

- name: Run tests
- name: Create venv and install dependencies (Unix)
if: runner.os == 'Linux'
run: |
uv venv .test-venv
source .test-venv/bin/activate
uv pip install rtc-wheel/*.whl ./livekit-api ./livekit-protocol
uv pip install pytest pytest-asyncio numpy matplotlib

- name: Create venv and install dependencies (macOS)
if: runner.os == 'macOS'
run: |
uv venv .test-venv
source .test-venv/bin/activate
uv pip install "${{ steps.select-wheel-macos.outputs.wheel }}"
uv pip install ./livekit-api ./livekit-protocol
uv pip install pytest pytest-asyncio numpy matplotlib

- name: Create venv and install dependencies (Windows)
if: runner.os == 'Windows'
run: |
uv venv .test-venv
$wheel = (Get-ChildItem rtc-wheel\*.whl)[0].FullName
uv pip install --python .test-venv $wheel .\livekit-api .\livekit-protocol
uv pip install --python .test-venv pytest pytest-asyncio numpy matplotlib
shell: pwsh

- name: Run tests (Unix)
if: runner.os != 'Windows'
env:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
run: |

uv run python ./livekit-rtc/rust-sdks/download_ffi.py --output livekit-rtc/livekit/rtc/resources
uv add ./livekit-rtc ./livekit-api ./livekit-protocol
uv run pytest . --ignore=livekit-rtc/rust-sdks
source .test-venv/bin/activate
pytest tests/

- name: Run tests (Windows)
if: runner.os == 'Windows'
env:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
run: .test-venv\Scripts\python.exe -m pytest tests/
shell: pwsh

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
22 changes: 0 additions & 22 deletions livekit-rtc/hatch_build.py

This file was deleted.

56 changes: 30 additions & 26 deletions livekit-rtc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[build-system]
requires = ["hatchling", "requests"]
build-backend = "hatchling.build"
requires = [
"setuptools>=61",
"wheel",
"requests",
]
build-backend = "setuptools.build_meta"

[project]
name = "livekit"
Expand Down Expand Up @@ -35,34 +39,34 @@ Documentation = "https://docs.livekit.io"
Website = "https://livekit.io/"
Source = "https://github.com/livekit/python-sdks/"

[tool.hatch.version]
path = "livekit/rtc/version.py"

[tool.hatch.build.targets.wheel]
packages = ["livekit"]
artifacts = [
"livekit/rtc/resources/*.so",
"livekit/rtc/resources/*.dylib",
"livekit/rtc/resources/*.dll",
]
[tool.setuptools.dynamic]
version = { attr = "livekit.rtc.version.__version__" }

[tool.hatch.build.targets.wheel.hooks.custom]
path = "hatch_build.py"
[tool.setuptools.packages.find]
include = ["livekit.*"]

[tool.hatch.build.targets.sdist]
include = ["/livekit", "/rust-sdks"]
[tool.setuptools.package-data]
"livekit.rtc" = ["_proto/*.py", "py.typed", "*.pyi", "**/*.pyi"]
"livekit.rtc.resources" = [
"*.so",
"*.dylib",
"*.dll",
"LICENSE.md",
"*.h",
"jupyter-html/index.html",
]

[tool.cibuildwheel]
build = "cp39-*"
skip = "*-musllinux_*" # not supported (libwebrtc is using glibc)

skip = "*-musllinux_*" # not supported (libwebrtc requires glibc)
before-build = "pip install requests && python rust-sdks/download_ffi.py --output livekit/rtc/resources"

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

[[tool.cibuildwheel.overrides]]
select = "*macosx_arm64"
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
Loading
Loading