diff --git a/.github/workflows/python-safpy.yml b/.github/workflows/python-safpy.yml index c623ffc..5c4e6e9 100644 --- a/.github/workflows/python-safpy.yml +++ b/.github/workflows/python-safpy.yml @@ -14,42 +14,82 @@ permissions: jobs: build-and-test: - runs-on: ubuntu-latest + + name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: - python-version: "3.10" - - name: Install dependencies + python-version: ${{ matrix.python-version }} + - name: Install Python package dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install cffi numpy spaudiopy - name: Checkout submodules - run: git submodule update --init --recursive - - - name: Dependency packages - run: | - sudo apt-get update && sudo apt-get install libsndfile1 liblapack3 liblapack-dev libopenblas-base libopenblas-dev liblapacke-dev - sudo ldconfig + run: git submodule update --init --recursive --depth=1 + + - name: Install system dependencies + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update && sudo apt-get install libsndfile1 liblapack3 liblapack-dev libopenblas-base libopenblas-dev liblapacke-dev + sudo ldconfig + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install openblas + elif [ "$RUNNER_OS" == "Windows" ]; then + curl https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.26/OpenBLAS-0.3.26-x64.zip -L -o tmp.zip + 7z x ./tmp.zip -oOpenBLAS + cp ./OpenBLAS/lib/libopenblas.lib $GITHUB_WORKSPACE + cp ./OpenBLAS/bin/libopenblas.dll $GITHUB_WORKSPACE + echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH + else + echo "$RUNNER_OS not supported" + exit 1 + fi + shell: bash - - name: Configure CMake (Linux) + - name: Configure CMake # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 run: | cmake -E make_directory ./Spatial_Audio_Framework/build - cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DSAF_BUILD_EXAMPLES=0 + if [ "$RUNNER_OS" == "Linux" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DSAF_BUILD_EXAMPLES=0 + elif [ "$RUNNER_OS" == "macOS" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_APPLE_ACCELERATE -DSAF_BUILD_EXAMPLES=0 + elif [ "$RUNNER_OS" == "Windows" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DOPENBLAS_LIBRARY=$GITHUB_WORKSPACE/OpenBLAS/lib/libopenblas.lib -DLAPACKE_LIBRARY=$GITHUB_WORKSPACE/OpenBLAS/lib/libopenblas.lib -DOPENBLAS_HEADER_PATH=$GITHUB_WORKSPACE/OpenBLAS/include/ -DSAF_BUILD_EXAMPLES=0 + fi + shell: bash + - name: Build SAF # Execute the build. You can specify a specific target with "--target " - run: cmake --build ./Spatial_Audio_Framework/build + run: cmake --build ./Spatial_Audio_Framework/build -j2 + + - name: Print shared object dependencies + if: ${{ contains( runner.os, 'Linux' ) }} + run: ldd ./Spatial_Audio_Framework/build/test/saf_test + - name: Test SAF run: | - ldd ./Spatial_Audio_Framework/build/test/saf_test - ./Spatial_Audio_Framework/build/test/saf_test + if [ "$RUNNER_OS" != "Windows" ]; then + ./Spatial_Audio_Framework/build/test/saf_test + else + cp ./Spatial_Audio_Framework/build/test/Debug/saf_test.exe ./Spatial_Audio_Framework/build/test/ + cp ./Spatial_Audio_Framework/build/framework/Debug/saf.lib ./Spatial_Audio_Framework/build/framework/ + + ./Spatial_Audio_Framework/build/test/saf_test.exe + fi + shell: bash - name: Lint with flake8 run: | @@ -58,8 +98,11 @@ jobs: # 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 package + run: python setup.py build + - name: Build and install package run: python -m pip install -e . + - name: Test with pytest - run: | - pytest -vvv + run: pytest -vvv diff --git a/Spatial_Audio_Framework b/Spatial_Audio_Framework index 868bcc9..018e06e 160000 --- a/Spatial_Audio_Framework +++ b/Spatial_Audio_Framework @@ -1 +1 @@ -Subproject commit 868bcc9ae46913339110d2c9e42e75ef22ce2c7a +Subproject commit 018e06e86ccdbb37cc527ca511a3a26576126b71 diff --git a/safpy_build.py b/safpy_build.py index 597b964..2774236 100644 --- a/safpy_build.py +++ b/safpy_build.py @@ -19,22 +19,45 @@ # Sensible default, please adjust if needed. # In case of doubt, you can also check numpy.show_config() for its BLAS +print("Detected platform: " + sys.platform) if sys.platform == "darwin": print("SAFPY using default Apple Accelerate") extra_link_args.extend(['-Wl,-framework', '-Wl,Accelerate']) -else: +elif sys.platform == "linux": print("SAFPY using default OpenBLAS/LAPACKE") saf_performance_lib.extend(["openblas", "lapacke"]) - +elif sys.platform == "win32": + print("SAFPY using default OpenBLAS/LAPACKE") + saf_performance_lib.extend(["libopenblas"]) # should include lapacke +else: + print("No defaults.") # cdef() expects a single string declaring the C types, functions and # globals needed to use the shared object. It must be in valid C syntax. ffibuilder.cdef(""" #define SAF_VERSION ... + +""") + +if sys.platform != "win32": + ffibuilder.cdef(""" -typedef float _Complex float_complex; -typedef double _Complex double_complex; + typedef float _Complex float_complex; + typedef double _Complex double_complex; + + """) +else: + ffibuilder.cdef(""" + + typedef struct + { + float _Val[2]; + } float_complex; + + """) + +ffibuilder.cdef(""" typedef enum _AFSTFT_FDDATA_FORMAT{ AFSTFT_BANDS_CH_TIME, /**< nBands x nChannels x nTimeHops */ @@ -42,7 +65,6 @@ }AFSTFT_FDDATA_FORMAT; - void *malloc(size_t size); void free(void *ptr); @@ -201,6 +223,9 @@ libraries.extend(saf_performance_lib) +library_dirs.extend([this_dir, saf_path]) + + print("Compiling _safpy with:") print(f"C_Header_Source: {c_header_source}") print(f"include_dirs: {include_dirs}")