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
12 changes: 12 additions & 0 deletions cel_expr_python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,15 @@ py_test(
],
}),
)

# Platform definition for macOS x86_64.
# Used for cross-compiling from arm64 macOS hosts (Apple Silicon) to x86_64.
# This is passed to Bazel via --platforms in setup.py when building x86_64 wheels.
platform(
name = "macos_x86_64",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
visibility = ["//visibility:public"],
)
2 changes: 2 additions & 0 deletions release/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ container-engine = "docker; disable_host_mount: True"
before-all = "git config --global http.sslVerify false && echo 'Installing bazelisk' && cp {project}/bazelisk-linux-amd64 /usr/local/bin/bazel"

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

[tool.cibuildwheel.windows]
# Bazel is expected to be already installed and in the PATH on Windows.
27 changes: 26 additions & 1 deletion release/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import glob
import os
import platform
import re
import shutil
import subprocess
Expand Down Expand Up @@ -161,7 +162,31 @@ def platform_config_windows(self, cmd, python_version):

def platform_config_macos(self, cmd):
"""Applies macOS-specific Bazel configurations."""
cmd.extend(['--macos_minimum_os=10.13', '--cxxopt=-faligned-allocation'])
deployment_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', '10.13')
cmd.extend([
f'--macos_minimum_os={deployment_target}',
'--cxxopt=-faligned-allocation',
])

archflags = os.environ.get('ARCHFLAGS', '')
if 'x86_64' in archflags:
target_arch = 'x86_64'
elif 'arm64' in archflags:
target_arch = 'arm64'
else:
machine = platform.machine()
if machine in ('AMD64', 'x86_64'):
target_arch = 'x86_64'
elif machine in ('arm64', 'aarch64'):
target_arch = 'arm64'
else:
target_arch = machine

print(f'Target architecture for macOS: {target_arch}', flush=True)
cmd.append(f'--macos_cpus={target_arch}')
cmd.append(f'--cpu=darwin_{target_arch}')
if target_arch == 'x86_64':
cmd.append('--platforms=//cel_expr_python:macos_x86_64')


setuptools.setup(
Expand Down
Loading