Skip to content

Commit cfa52d3

Browse files
Add macOS/i86 wheels
PiperOrigin-RevId: 932631343
1 parent 9d5a61d commit cfa52d3

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

cel_expr_python/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,12 @@ py_test(
177177
],
178178
}),
179179
)
180+
181+
platform(
182+
name = "macos_x86_64",
183+
constraint_values = [
184+
"@platforms//os:osx",
185+
"@platforms//cpu:x86_64",
186+
],
187+
visibility = ["//visibility:public"],
188+
)

release/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ container-engine = "docker; disable_host_mount: True"
5454
before-all = "git config --global http.sslVerify false && echo 'Installing bazelisk' && cp {project}/bazelisk-linux-amd64 /usr/local/bin/bazel"
5555

5656
[tool.cibuildwheel.macos]
57+
archs = ["x86_64", "arm64"]
5758
before-all = "echo 'Installing bazelisk'; brew install bazelisk"
59+
environment = { MACOSX_DEPLOYMENT_TARGET = "10.13" }
5860

5961
[tool.cibuildwheel.windows]
6062
# Bazel is expected to be already installed and in the PATH on Windows.

release/setup.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import glob
1818
import os
19+
import platform
1920
import re
2021
import shutil
2122
import subprocess
@@ -161,7 +162,31 @@ def platform_config_windows(self, cmd, python_version):
161162

162163
def platform_config_macos(self, cmd):
163164
"""Applies macOS-specific Bazel configurations."""
164-
cmd.extend(['--macos_minimum_os=10.13', '--cxxopt=-faligned-allocation'])
165+
deployment_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', '10.13')
166+
cmd.extend([
167+
f'--macos_minimum_os={deployment_target}',
168+
'--cxxopt=-faligned-allocation',
169+
])
170+
171+
archflags = os.environ.get('ARCHFLAGS', '')
172+
if 'x86_64' in archflags:
173+
target_arch = 'x86_64'
174+
elif 'arm64' in archflags:
175+
target_arch = 'arm64'
176+
else:
177+
machine = platform.machine()
178+
if machine in ('AMD64', 'x86_64'):
179+
target_arch = 'x86_64'
180+
elif machine in ('arm64', 'aarch64'):
181+
target_arch = 'arm64'
182+
else:
183+
target_arch = machine
184+
185+
print(f'Target architecture for macOS: {target_arch}', flush=True)
186+
cmd.append(f'--macos_cpus={target_arch}')
187+
cmd.append(f'--cpu=darwin_{target_arch}')
188+
if target_arch == 'x86_64':
189+
cmd.append('--platforms=//cel_expr_python:macos_x86_64')
165190

166191

167192
setuptools.setup(

0 commit comments

Comments
 (0)