diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f29e5c0..6a609c7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11", "3.12"] - os: [ubuntu-latest, macos-13] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v3 @@ -25,19 +25,37 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} + - name: Install libomp on macOS + if: matrix.os == 'macos-latest' + run: | + brew install libomp - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install flake8 pytest pip install "numpy<2.0" numba - pip install torch --index-url https://download.pytorch.org/whl/cpu + - name: Install torch (mac) + if: matrix.os == 'macos-latest' + run: pip install torch + - name: Install torch (ubuntu) + if: matrix.os == 'ubuntu-latest' + run: pip install torch --index-url https://download.pytorch.org/whl/cpu - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Build CPP extension + - name: Build CPP extension with clang++ + if: matrix.os == 'macos-latest' + run: | + export CXX=$(brew --prefix llvm@15)/bin/clang++ + export LDFLAGS="-L/usr/local/opt/libomp/lib" + export CPPFLAGS="-I/usr/local/opt/libomp/include" + python setup.py build + find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; + - name: Build CPP extension with g++ + if: matrix.os == 'ubuntu-latest' run: | python setup.py build find build/ -name "_C*.so" -exec cp {} ./torchlpc/ \; diff --git a/setup.py b/setup.py index c52786f..70acd1c 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def get_extensions(): extra_compile_args = {} if use_openmp: extra_compile_args["cxx"] = ["-fopenmp"] - extra_link_args.append("-lgomp") + extra_link_args.append("-fopenmp") this_dir = os.path.abspath(os.path.dirname(__file__)) extensions_dir = os.path.join(this_dir, library_name, "csrc") @@ -59,9 +59,6 @@ def get_extensions(): return ext_modules -extra_link_args = [] -extra_compile_args = {} - setuptools.setup( name=library_name, version=VERSION,