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
92 changes: 0 additions & 92 deletions livekit-rtc/hatch_build.py

This file was deleted.

39 changes: 21 additions & 18 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,28 +39,27 @@ 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 requires glibc)
before-build = "pip install requests && python rust-sdks/download_ffi.py --output livekit/rtc/resources"
# Note: manylinux_2_28 is the default in cibuildwheel 3.x, no explicit config needed

# 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+
Expand All @@ -66,4 +69,4 @@ environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }

[[tool.cibuildwheel.overrides]]
select = "*macosx_arm64"
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
77 changes: 77 additions & 0 deletions livekit-rtc/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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.

"""Custom setup.py for platform-specific wheel tagging.

This file exists solely to customize the wheel platform tag. All package metadata
is defined in pyproject.toml.

The native FFI libraries (.so/.dylib/.dll) require specific platform tags that
respect MACOSX_DEPLOYMENT_TARGET and ARCHFLAGS environment variables set by
cibuildwheel, rather than using sysconfig.get_platform() which returns Python's
compile-time values.
"""

import os
import platform
import sys

import setuptools # type: ignore
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel # type: ignore


def get_platform_tag():
"""Get the wheel platform tag for the current/target platform."""
if sys.platform == "darwin":
# Get deployment target from environment (set by cibuildwheel) or fall back
target = os.environ.get("MACOSX_DEPLOYMENT_TARGET")
if not target:
target = platform.mac_ver()[0]
parts = target.split(".")
target = f"{parts[0]}.{parts[1] if len(parts) > 1 else '0'}"

version_tag = target.replace(".", "_")

# Check ARCHFLAGS for cross-compilation (cibuildwheel sets this)
archflags = os.environ.get("ARCHFLAGS", "")
if "-arch arm64" in archflags:
arch = "arm64"
elif "-arch x86_64" in archflags:
arch = "x86_64"
else:
arch = platform.machine()

return f"macosx_{version_tag}_{arch}"
elif sys.platform == "linux":
return f"linux_{platform.machine()}"
elif sys.platform == "win32":
arch = platform.machine()
if arch == "AMD64":
arch = "amd64"
return f"win_{arch}"
else:
return f"{platform.system().lower()}_{platform.machine()}"


class bdist_wheel(_bdist_wheel):
def finalize_options(self):
self.plat_name = get_platform_tag()
_bdist_wheel.finalize_options(self)


setuptools.setup(
cmdclass={
"bdist_wheel": bdist_wheel,
},
)