|
16 | 16 |
|
17 | 17 | import glob |
18 | 18 | import os |
| 19 | +import platform |
19 | 20 | import re |
20 | 21 | import shutil |
21 | 22 | import subprocess |
@@ -113,6 +114,12 @@ def build_extension(self, ext): |
113 | 114 |
|
114 | 115 | print(f'Copying {found} to {dest_path}') |
115 | 116 | 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}') |
116 | 123 |
|
117 | 124 | def platform_config_windows(self, cmd, python_version): |
118 | 125 | """Applies Windows-specific Bazel workarounds for Hermetic Python.""" |
@@ -163,6 +170,24 @@ def platform_config_macos(self, cmd): |
163 | 170 | """Applies macOS-specific Bazel configurations.""" |
164 | 171 | cmd.extend(['--macos_minimum_os=10.13', '--cxxopt=-faligned-allocation']) |
165 | 172 |
|
| 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 | + cmd.append(f'--cpu=darwin_{target_arch}') |
| 190 | + |
166 | 191 |
|
167 | 192 | setuptools.setup( |
168 | 193 | name='cel-expr-python', |
|
0 commit comments