Skip to content

Commit 86d2d40

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

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

release/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ 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"
5859

5960
[tool.cibuildwheel.windows]

release/setup.py

Lines changed: 24 additions & 0 deletions
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
@@ -113,6 +114,12 @@ def build_extension(self, ext):
113114

114115
print(f'Copying {found} to {dest_path}')
115116
shutil.copyfile(found, dest_path)
117+
if sys.platform == 'darwin':
118+
try:
119+
print(f'Checking file architecture for {dest_path}:')
120+
subprocess.call(['file', dest_path])
121+
except Exception as e:
122+
print(f'Failed to run file command: {e}')
116123

117124
def platform_config_windows(self, cmd, python_version):
118125
"""Applies Windows-specific Bazel workarounds for Hermetic Python."""
@@ -163,6 +170,23 @@ def platform_config_macos(self, cmd):
163170
"""Applies macOS-specific Bazel configurations."""
164171
cmd.extend(['--macos_minimum_os=10.13', '--cxxopt=-faligned-allocation'])
165172

173+
archflags = os.environ.get('ARCHFLAGS', '')
174+
if 'x86_64' in archflags:
175+
target_arch = 'x86_64'
176+
elif 'arm64' in archflags:
177+
target_arch = 'arm64'
178+
else:
179+
machine = platform.machine()
180+
if machine in ('AMD64', 'x86_64'):
181+
target_arch = 'x86_64'
182+
elif machine in ('arm64', 'aarch64'):
183+
target_arch = 'arm64'
184+
else:
185+
target_arch = machine
186+
187+
print(f'Target architecture for macOS: {target_arch}')
188+
cmd.append(f'--macos_cpus={target_arch}')
189+
166190

167191
setuptools.setup(
168192
name='cel-expr-python',

0 commit comments

Comments
 (0)