Skip to content

Commit d92a7f3

Browse files
authored
setup uv workspace (#542)
1 parent 8423764 commit d92a7f3

File tree

15 files changed

+4300
-247
lines changed

15 files changed

+4300
-247
lines changed

.github/workflows/check-types.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ jobs:
2222
with:
2323
python-version: 3.9
2424

25-
- name: Download ffi
26-
run: python -m pip install requests && python livekit-rtc/rust-sdks/download_ffi.py --output $(python -m site --user-site)/livekit/rtc/resources
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
enable-cache: true
29+
cache-dependency-glob: "uv.lock"
2730

28-
- name: Install mypy
29-
run: python -m pip install --upgrade mypy
31+
- name: Install the project
32+
run: uv sync --all-extras --dev
3033

31-
- name: Install packages
32-
run: python -m pip install pytest ./livekit-api ./livekit-protocol ./livekit-rtc pydantic numpy ipython
34+
- name: Install workspace packages
35+
run: uv pip install -e livekit-protocol -e livekit-api -e livekit-rtc
36+
37+
- name: Download ffi
38+
run: uv run python livekit-rtc/rust-sdks/download_ffi.py --output .venv/lib/python3.9/site-packages/livekit/rtc/resources
3339

3440
- name: Check Types
35-
run: python -m mypy --install-type --non-interactive -p 'livekit-protocol' -p 'livekit-api' -p 'livekit-rtc'
41+
run: uv run mypy livekit-protocol livekit-api livekit-rtc

.github/workflows/ruff.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ jobs:
99
with:
1010
python-version: "3.9"
1111

12-
- name: Install dependencies
13-
run: |
14-
python -m pip install --upgrade pip
15-
pip install ruff
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v5
14+
with:
15+
enable-cache: true
16+
cache-dependency-glob: "uv.lock"
17+
18+
- name: Install the project
19+
run: uv sync --all-extras --dev
1620

1721
- name: Ruff livekit-api
18-
run: ruff check --output-format=github .
22+
run: uvx ruff check --output-format=github .
1923

2024
- name: Check format
21-
run: ruff format --check .
25+
run: uvx ruff format --check .

.github/workflows/tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@ jobs:
1818
with:
1919
submodules: true
2020
lfs: true
21+
- name: Install uv
22+
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "uv.lock"
27+
28+
- name: Install the project
29+
run: uv sync --all-extras --dev
2130

2231
- uses: actions/setup-python@v6
2332
with:
2433
python-version: '3.13'
34+
2535
- name: Run tests
2636
env:
2737
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
2838
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
2939
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
3040
run: |
31-
pip3 install -r dev-requirements.txt
32-
python3 ./livekit-rtc/rust-sdks/download_ffi.py --output livekit-rtc/livekit/rtc/resources
33-
pip3 install ./livekit-protocol ./livekit-api ./livekit-rtc
34-
pytest . --ignore=livekit-rtc/rust-sdks
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
3545

dev-requirements.txt

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

livekit-api/pyproject.toml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=42",
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "livekit-api"
7+
dynamic = ["version"]
8+
description = "Python Server API for LiveKit"
9+
readme = "README.md"
10+
requires-python = ">=3.9.0"
11+
license = "Apache-2.0"
12+
keywords = ["webrtc", "realtime", "audio", "video", "livekit"]
13+
authors = [
14+
{ name = "LiveKit", email = "[email protected]" }
415
]
5-
build-backend = "setuptools.build_meta"
16+
classifiers = [
17+
"Intended Audience :: Developers",
18+
"Topic :: Multimedia :: Sound/Audio",
19+
"Topic :: Multimedia :: Video",
20+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.7",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3 :: Only",
27+
]
28+
dependencies = [
29+
"pyjwt>=2.0.0",
30+
"aiohttp>=3.9.0",
31+
"protobuf>=4",
32+
"types-protobuf>=4",
33+
"livekit-protocol>=1.1.1,<2.0.0",
34+
]
35+
36+
[project.urls]
37+
Documentation = "https://docs.livekit.io"
38+
Website = "https://livekit.io/"
39+
Source = "https://github.com/livekit/python-sdks/"
40+
41+
[tool.uv.sources]
42+
livekit-protocol = { workspace = true }
43+
44+
[tool.hatch.version]
45+
path = "livekit/api/version.py"
46+
47+
[tool.hatch.build.targets.wheel]
48+
packages = ["livekit"]
49+
50+
[tool.hatch.build.targets.sdist]
51+
include = ["/livekit"]

livekit-api/setup.py

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

livekit-protocol/pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "livekit-protocol"
7+
dynamic = ["version"]
8+
description = "Python protocol stubs for LiveKit"
9+
requires-python = ">=3.7.0"
10+
license = "Apache-2.0"
11+
readme = { content-type = "text/plain", text = "Python protocol stubs for LiveKit" }
12+
keywords = ["webrtc", "realtime", "audio", "video", "livekit"]
13+
authors = [
14+
{ name = "LiveKit", email = "[email protected]" }
15+
]
16+
classifiers = [
17+
"Intended Audience :: Developers",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.7",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3 :: Only",
24+
]
25+
dependencies = [
26+
"protobuf>=4",
27+
"types-protobuf>=4",
28+
]
29+
30+
[project.urls]
31+
Documentation = "https://docs.livekit.io"
32+
Website = "https://livekit.io/"
33+
Source = "https://github.com/livekit/python-sdks/"
34+
35+
[tool.hatch.version]
36+
path = "livekit/protocol/version.py"
37+
38+
[tool.hatch.build.targets.wheel]
39+
packages = ["livekit"]
40+
41+
[tool.hatch.build.targets.sdist]
42+
include = ["/livekit"]

livekit-protocol/setup.py

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

livekit-rtc/hatch_build.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2023 LiveKit, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
16+
17+
18+
class CustomBuildHook(BuildHookInterface):
19+
def initialize(self, version, build_data):
20+
"""Force platform-specific wheel due to native libraries"""
21+
build_data["pure_python"] = False
22+
build_data["infer_tag"] = True

0 commit comments

Comments
 (0)