Skip to content

Commit

Permalink
Merge pull request #18 from tuwien-cms/fix_mac
Browse files Browse the repository at this point in the history
Fix compilation error on Mac
  • Loading branch information
shinaoka authored Jun 24, 2024
2 parents e88160f + 5ab6d04 commit d65ac50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit d65ac50

Please sign in to comment.