From b98affe776cc7f68e44092f97c4d2bdef886cce5 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Tue, 16 Dec 2025 11:11:08 +0100 Subject: [PATCH] migrate build backend to hatch --- livekit-api/pyproject.toml | 15 +++++-- livekit-api/setup.py | 64 --------------------------- livekit-protocol/pyproject.toml | 15 +++++-- livekit-protocol/setup.py | 58 ------------------------- livekit-rtc/hatch_build.py | 22 ++++++++++ livekit-rtc/pyproject.toml | 23 ++++++++-- livekit-rtc/setup.py | 76 --------------------------------- 7 files changed, 66 insertions(+), 207 deletions(-) delete mode 100644 livekit-api/setup.py delete mode 100644 livekit-protocol/setup.py create mode 100644 livekit-rtc/hatch_build.py delete mode 100644 livekit-rtc/setup.py diff --git a/livekit-api/pyproject.toml b/livekit-api/pyproject.toml index 6ea86f82..eb14c2f3 100644 --- a/livekit-api/pyproject.toml +++ b/livekit-api/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "livekit-api" -version = "0.8.0" +dynamic = ["version"] description = "Python Server API for LiveKit" readme = "README.md" requires-python = ">=3.9.0" @@ -40,3 +40,12 @@ Source = "https://github.com/livekit/python-sdks/" [tool.uv.sources] livekit-protocol = { workspace = true } + +[tool.hatch.version] +path = "livekit/api/version.py" + +[tool.hatch.build.targets.wheel] +packages = ["livekit"] + +[tool.hatch.build.targets.sdist] +include = ["/livekit"] diff --git a/livekit-api/setup.py b/livekit-api/setup.py deleted file mode 100644 index 97a64d67..00000000 --- a/livekit-api/setup.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2023 LiveKit, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import pathlib -from typing import Any, Dict - -import setuptools # type: ignore - -here = pathlib.Path(__file__).parent.resolve() -about: Dict[Any, Any] = {} -with open(os.path.join(here, "livekit", "api", "version.py"), "r") as f: - exec(f.read(), about) - - -setuptools.setup( - name="livekit-api", - version=about["__version__"], - description="Python Server API for LiveKit", - long_description=(here / "README.md").read_text(encoding="utf-8"), - long_description_content_type="text/markdown", - url="https://github.com/livekit/python-sdks", - classifiers=[ - "Intended Audience :: Developers", - "Topic :: Multimedia :: Sound/Audio", - "Topic :: Multimedia :: Video", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3 :: Only", - ], - keywords=["webrtc", "realtime", "audio", "video", "livekit"], - packages=setuptools.find_namespace_packages(include=["livekit.*"]), - python_requires=">=3.9.0", - install_requires=[ - "pyjwt>=2.0.0", - "aiohttp>=3.9.0", - "protobuf>=4", - "types-protobuf>=4", - "livekit-protocol>=1.1.1,<2.0.0", - ], - package_data={ - "livekit.api": ["py.typed", "*.pyi", "**/*.pyi"], - }, - project_urls={ - "Documentation": "https://docs.livekit.io", - "Website": "https://livekit.io/", - "Source": "https://github.com/livekit/python-sdks/", - }, -) diff --git a/livekit-protocol/pyproject.toml b/livekit-protocol/pyproject.toml index 00b9aa6c..5901cc0b 100644 --- a/livekit-protocol/pyproject.toml +++ b/livekit-protocol/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "livekit-protocol" -version = "1.1.1" +dynamic = ["version"] description = "Python protocol stubs for LiveKit" requires-python = ">=3.7.0" license = "Apache-2.0" @@ -31,3 +31,12 @@ dependencies = [ Documentation = "https://docs.livekit.io" Website = "https://livekit.io/" Source = "https://github.com/livekit/python-sdks/" + +[tool.hatch.version] +path = "livekit/protocol/version.py" + +[tool.hatch.build.targets.wheel] +packages = ["livekit"] + +[tool.hatch.build.targets.sdist] +include = ["/livekit"] diff --git a/livekit-protocol/setup.py b/livekit-protocol/setup.py deleted file mode 100644 index 6b08d7af..00000000 --- a/livekit-protocol/setup.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2023 LiveKit, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import pathlib -from typing import Any, Dict - -import setuptools # type: ignore - -here = pathlib.Path(__file__).parent.resolve() -about: Dict[Any, Any] = {} -with open(os.path.join(here, "livekit", "protocol", "version.py"), "r") as f: - exec(f.read(), about) - - -setuptools.setup( - name="livekit-protocol", - version=about["__version__"], - description="Python protocol stubs for LiveKit", - long_description="Python protocol stubs for LiveKit", - long_description_content_type="text/markdown", - url="https://github.com/livekit/python-sdks", - classifiers=[ - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3 :: Only", - ], - keywords=["webrtc", "realtime", "audio", "video", "livekit"], - packages=setuptools.find_namespace_packages(include=["livekit.*"]), - python_requires=">=3.7.0", - install_requires=[ - "protobuf>=4", - "types-protobuf>=4", - ], - package_data={ - "livekit.protocol": ["*.pyi", "**/*.pyi", "py.typed"], - }, - project_urls={ - "Documentation": "https://docs.livekit.io", - "Website": "https://livekit.io/", - "Source": "https://github.com/livekit/python-sdks/", - }, -) diff --git a/livekit-rtc/hatch_build.py b/livekit-rtc/hatch_build.py new file mode 100644 index 00000000..839d3072 --- /dev/null +++ b/livekit-rtc/hatch_build.py @@ -0,0 +1,22 @@ +# Copyright 2023 LiveKit, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + + +class CustomBuildHook(BuildHookInterface): + def initialize(self, version, build_data): + """Force platform-specific wheel due to native libraries""" + build_data["pure_python"] = False + build_data["infer_tag"] = True diff --git a/livekit-rtc/pyproject.toml b/livekit-rtc/pyproject.toml index 024152bc..c1ffe726 100644 --- a/livekit-rtc/pyproject.toml +++ b/livekit-rtc/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=42", "wheel", "requests"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "requests"] +build-backend = "hatchling.build" [project] name = "livekit" -version = "0.16.8" +dynamic = ["version"] description = "Python Real-time SDK for LiveKit" readme = "README.md" requires-python = ">=3.9.0" @@ -35,6 +35,23 @@ 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.hatch.build.targets.wheel.hooks.custom] +path = "hatch_build.py" + +[tool.hatch.build.targets.sdist] +include = ["/livekit", "/rust-sdks"] + [tool.cibuildwheel] build = "cp39-*" skip = "*-musllinux_*" # not supported (libwebrtc is using glibc) diff --git a/livekit-rtc/setup.py b/livekit-rtc/setup.py deleted file mode 100644 index 25ca9a25..00000000 --- a/livekit-rtc/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2023 LiveKit, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import pathlib -from sysconfig import get_platform -from typing import Any, Dict - -import setuptools # type: ignore -import setuptools.command.build_py # type: ignore -from wheel.bdist_wheel import bdist_wheel as _bdist_wheel # type: ignore - -here = pathlib.Path(__file__).parent.resolve() -about: Dict[Any, Any] = {} -with open(os.path.join(here, "livekit", "rtc", "version.py"), "r") as f: - exec(f.read(), about) - - -class bdist_wheel(_bdist_wheel): - def finalize_options(self): - self.plat_name = get_platform() # force a platform tag - _bdist_wheel.finalize_options(self) - - -setuptools.setup( - name="livekit", - version=about["__version__"], - description="Python Real-time SDK for LiveKit", - long_description=(here / "README.md").read_text(encoding="utf-8"), - long_description_content_type="text/markdown", - url="https://github.com/livekit/python-sdks", - cmdclass={ - "bdist_wheel": bdist_wheel, - }, - classifiers=[ - "Intended Audience :: Developers", - "Topic :: Multimedia :: Sound/Audio", - "Topic :: Multimedia :: Video", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3 :: Only", - ], - keywords=["webrtc", "realtime", "audio", "video", "livekit"], - packages=setuptools.find_namespace_packages(include=["livekit.*"]), - python_requires=">=3.9.0", - install_requires=["protobuf>=4.25.0", "types-protobuf>=3", "aiofiles>=24", "numpy>=1.26"], - package_data={ - "livekit.rtc": ["_proto/*.py", "py.typed", "*.pyi", "**/*.pyi"], - "livekit.rtc.resources": [ - "*.so", - "*.dylib", - "*.dll", - "LICENSE.md", - "*.h", - "jupyter-html/index.html", - ], - }, - project_urls={ - "Documentation": "https://docs.livekit.io", - "Website": "https://livekit.io/", - "Source": "https://github.com/livekit/python-sdks/", - }, -)