From 307044d5fcbc92462d71c53d06979cfa070d7b8b Mon Sep 17 00:00:00 2001 From: Navaneet Villodi <11260095+nauaneed@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:29:14 +0530 Subject: [PATCH] ci(macos): use omp enabled homebrew-llvm-clang Ref - https://github.com/Rdatatable/data.table/wiki/Installation/370c4629742886190c08de5e199a8ca8d3d86b24 - https://github.com/actions/runner-images/blob/5c04ad10e394b07619bd68a62b3cd7665e7a3cb3/images/macos/macos-14-arm64-Readme.md --- .github/workflows/tests.yml | 6 ++++++ setup.py | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 853420fc..ea30f8f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,6 +38,12 @@ jobs: if: ${{ runner.os != 'Windows' }} - name: Install dependencies run: | + if [ "$RUNNER_OS" == "macOS" ]; then + export CC="$(brew --prefix llvm@15)/bin/clang" + export CXX="$(brew --prefix llvm@15)/bin/clang++" + CPPFLAGS = "-I$(brew --prefix libomp)/include" + LDFLAGS = "-L$(brew --prefix libomp)/lib" + fi conda info conda install -c conda-forge numpy cython h5py python -m pip install --upgrade pip setuptools wheel diff --git a/setup.py b/setup.py index ffd82ef1..36397324 100644 --- a/setup.py +++ b/setup.py @@ -128,7 +128,15 @@ def _get_openmp_flags(): elif sys.platform == 'darwin': if (os.environ.get('CC') is not None and os.environ.get('CXX') is not None): - return ['-fopenmp'], ['-fopenmp'] + cppflags = os.environ.get('CPPFLAGS') + ldflags = os.environ.get('LDFLAGS') + if cppflags is not None ldflags is not None: + print('*'*80) + print(cppflags.split(", ")) + print(ldflags.split(", ")) + return cppflags.split(", "), ldflags.split(", ") + else: + return ['-fopenmp'], ['-fopenmp'] else: return ['-Xpreprocessor', '-fopenmp'], ['-lomp'] else: