Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to fix compilation error on Mac #18

Merged
merged 13 commits into from
Jun 24, 2024
3 changes: 3 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- os: macos-12
numpy-version: auto
python-version: 3.9
- os: macos-latest
numpy-version: auto
python-version: 3.11
steps:
- uses: actions/checkout@v4

Expand Down
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT
import io
import os.path
import os
import platform
import re

Expand Down Expand Up @@ -142,9 +143,24 @@ def build_extensions(self):
if "-arch" in flags_dict:
flags_dict["-march"] = flags_dict.pop("-arch")

# Remove any existing -mtune, -march, -arch flags if not self.opt_arch
if not self.opt_arch:
for key in ["-mtune", "-march", "-arch"]:
if key in flags_dict:
del flags_dict[key]

flags_dict.update(new_flags)
self.compiler.compiler_so = make_exec_string(cc_so, flags_dict)

# clang on 14.4.1 fails to include C header files...
if platform.system() == 'Darwin':
sdk_path = (
"/Applications/Xcode.app/Contents/Developer/Platforms/"
"MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
)
current_cpath = os.environ.get('CPATH', '')
os.environ['CPATH'] = f"{sdk_path}:{current_cpath}"

# This has to be set to false because MacOS does not ship openmp
# by default.
if self.with_openmp is None:
Expand Down