Skip to content

Commit 950f732

Browse files
committed
fix macosx target
1 parent c0096aa commit 950f732

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

livekit-rtc/pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ build-backend = "setuptools.build_meta"
1010
build = "cp39-*"
1111
skip = "*-musllinux_*" # not supported (libwebrtc requires glibc)
1212
before-build = "pip install requests && python rust-sdks/download_ffi.py --output livekit/rtc/resources"
13+
14+
# macOS deployment targets must match the FFI binaries (see rust-sdks/.github/workflows/ffi-builds.yml)
15+
# x86_64 supports macOS 10.15+, arm64 requires macOS 11.0+
16+
[[tool.cibuildwheel.overrides]]
17+
select = "*macosx_x86_64"
18+
environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }
19+
20+
[[tool.cibuildwheel.overrides]]
21+
select = "*macosx_arm64"
22+
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }

livekit-rtc/setup.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
import os
1616
import pathlib
17-
from sysconfig import get_platform
17+
import platform
18+
import sys
1819
from typing import Any, Dict
1920

2021
import setuptools # type: ignore
21-
import setuptools.command.build_py # type: ignore
2222
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel # type: ignore
2323

2424
here = pathlib.Path(__file__).parent.resolve()
@@ -27,9 +27,47 @@
2727
exec(f.read(), about)
2828

2929

30+
def get_platform_tag():
31+
"""Get the wheel platform tag for the current/target platform.
32+
33+
On macOS, we must respect MACOSX_DEPLOYMENT_TARGET and ARCHFLAGS environment
34+
variables that cibuildwheel sets, rather than using sysconfig.get_platform()
35+
which returns Python's compile-time values.
36+
"""
37+
if sys.platform == "darwin":
38+
# Get deployment target from environment (set by cibuildwheel) or fall back
39+
target = os.environ.get("MACOSX_DEPLOYMENT_TARGET")
40+
if not target:
41+
target = platform.mac_ver()[0]
42+
parts = target.split(".")
43+
target = f"{parts[0]}.{parts[1] if len(parts) > 1 else '0'}"
44+
45+
version_tag = target.replace(".", "_")
46+
47+
# Check ARCHFLAGS for cross-compilation (cibuildwheel sets this)
48+
archflags = os.environ.get("ARCHFLAGS", "")
49+
if "-arch arm64" in archflags:
50+
arch = "arm64"
51+
elif "-arch x86_64" in archflags:
52+
arch = "x86_64"
53+
else:
54+
arch = platform.machine()
55+
56+
return f"macosx_{version_tag}_{arch}"
57+
elif sys.platform == "linux":
58+
return f"linux_{platform.machine()}"
59+
elif sys.platform == "win32":
60+
arch = platform.machine()
61+
if arch == "AMD64":
62+
arch = "amd64"
63+
return f"win_{arch}"
64+
else:
65+
return f"{platform.system().lower()}_{platform.machine()}"
66+
67+
3068
class bdist_wheel(_bdist_wheel):
3169
def finalize_options(self):
32-
self.plat_name = get_platform() # force a platform tag
70+
self.plat_name = get_platform_tag()
3371
_bdist_wheel.finalize_options(self)
3472

3573

0 commit comments

Comments
 (0)