Skip to content

Commit 7ed8aa5

Browse files
authored
fix: mac github actions
* fix: update linker flag for OpenMP support in setup.py * feat: add homebrew clang setup for macOS in CI workflow * fix: change export statement order * fix: specify llvm15 * only export cxx falg * fix: update macOS CI workflow to install libomp and clarify build steps * cfg: update include paths * cfg: use different index-url for different OS * test arm macos builds
1 parent 350f93d commit 7ed8aa5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

.github/workflows/python-package.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,45 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
python-version: ["3.9", "3.10", "3.11", "3.12"]
20-
os: [ubuntu-latest, macos-13]
20+
os: [ubuntu-latest, macos-latest]
2121

2222
steps:
2323
- uses: actions/checkout@v3
2424
- name: Set up Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v3
2626
with:
2727
python-version: ${{ matrix.python-version }}
28+
- name: Install libomp on macOS
29+
if: matrix.os == 'macos-latest'
30+
run: |
31+
brew install libomp
2832
- name: Install dependencies
2933
run: |
3034
python -m pip install --upgrade pip
3135
python -m pip install flake8 pytest
3236
pip install "numpy<2.0" numba
33-
pip install torch --index-url https://download.pytorch.org/whl/cpu
37+
- name: Install torch (mac)
38+
if: matrix.os == 'macos-latest'
39+
run: pip install torch
40+
- name: Install torch (ubuntu)
41+
if: matrix.os == 'ubuntu-latest'
42+
run: pip install torch --index-url https://download.pytorch.org/whl/cpu
3443
- name: Lint with flake8
3544
run: |
3645
# stop the build if there are Python syntax errors or undefined names
3746
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3847
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3948
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
40-
- name: Build CPP extension
49+
- name: Build CPP extension with clang++
50+
if: matrix.os == 'macos-latest'
51+
run: |
52+
export CXX=$(brew --prefix llvm@15)/bin/clang++
53+
export LDFLAGS="-L/usr/local/opt/libomp/lib"
54+
export CPPFLAGS="-I/usr/local/opt/libomp/include"
55+
python setup.py build
56+
find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \;
57+
- name: Build CPP extension with g++
58+
if: matrix.os == 'ubuntu-latest'
4159
run: |
4260
python setup.py build
4361
find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \;

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_extensions():
3434
extra_compile_args = {}
3535
if use_openmp:
3636
extra_compile_args["cxx"] = ["-fopenmp"]
37-
extra_link_args.append("-lgomp")
37+
extra_link_args.append("-fopenmp")
3838

3939
this_dir = os.path.abspath(os.path.dirname(__file__))
4040
extensions_dir = os.path.join(this_dir, library_name, "csrc")
@@ -59,9 +59,6 @@ def get_extensions():
5959
return ext_modules
6060

6161

62-
extra_link_args = []
63-
extra_compile_args = {}
64-
6562
setuptools.setup(
6663
name=library_name,
6764
version=VERSION,

0 commit comments

Comments
 (0)