Skip to content

Commit 19355b8

Browse files
committed
setup.py: arm64 macOS fixes
- Passing --target to CFLAGS and LDFLAGS based on ARCHFLAGS
1 parent 519f01c commit 19355b8

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: git submodule update --init --recursive
4444

4545
- name: Install cibuildwheel
46-
run: python3 -m pip install cibuildwheel==2.23.3
46+
run: python3 -m pip install cibuildwheel #==2.23.3
4747

4848
- name: Build wheels
4949
run: python3 -m cibuildwheel --output-dir wheelhouse

setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,22 @@ def build_package():
134134
#subprocess.check_call(['gcc', '-v', '-m32'], cwd=eC_dir, env=env)
135135
#subprocess.check_call(['gcc', '-print-sysroot', '-m32'], cwd=eC_dir, env=env)
136136
#subprocess.check_call([make_cmd, f'troubleshoot'], cwd=eC_dir, env=env)
137+
138+
archflags = env.get("ARCHFLAGS", "")
139+
# Convert the space-separated -arch into a single-word target flag (work-around for eC compiler not yet recognizing two arguments '-arch arm64')
140+
if "arm64" in archflags:
141+
archflags = "--target=arm64-apple-macos"
142+
elif "x86_64" in archflags:
143+
archflags = "--target=x86_64-apple-macos"
144+
else:
145+
archflags = None
146+
137147
make_and_args = [make_cmd, f'-j{cpu_count}', 'SKIP_SONAME=y'] #, 'V=1']
148+
if archflags is not None:
149+
# This will add arm64 architecture flags for macos-latest
150+
make_and_args.append('CFLAGS=' + archflags)
151+
make_and_args.append('LDFLAGS=' + archflags)
152+
138153
if cc_override is not None:
139154
make_and_args.extend(cc_override)
140155

0 commit comments

Comments
 (0)