π π A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Fix mutability for newer NumPy versions (3.14+) (#448)
Peter Sobote2b4fffb5e6a
diff --git a/.github/workflows/all.yml b/.github/workflows/all.ymlindex 95dfc4e..02831a4 100644--- a/.github/workflows/all.yml+++ b/.github/workflows/all.yml@@ -143,7 +143,7 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-${{ matrix.compiler }}-ccache+ key: ${{ matrix.os }}-${{ matrix.compiler }}-ccache- name: Build pedalboard locallyenv:CCACHE_DIR: ${{ github.workspace }}/.ccache@@ -190,7 +190,7 @@ jobs:matrix:include:- {- os: macos-13,+ os: macos-15-intel,python-version: "3.12",compiler: "clang",cc: "ccache clang",@@ -227,7 +227,7 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-${{ matrix.compiler }}-ccache+ key: ${{ matrix.os }}-${{ matrix.compiler }}-ccache- name: Build pedalboard locallyenv:CCACHE_DIR: ${{ github.workspace }}/.ccache@@ -241,7 +241,7 @@ jobs:# Use the minimum macOS deployment target supported by our version of PyBind:MACOSX_DEPLOYMENT_TARGET: "10.14"CCACHE_LOGFILE: ${{ github.workspace }}/.ccache_log- # This build caching is only to speed up tests on CI, so we only care about x86_64 for now.+ # This build caching is only to speed up tests on CI, so we only care about x86_64 (macos-15-intel runners).# Without limiting to a single architecture, ccache can't properly cache mixed Objective-C and C++ builds.# Fun fact: this is supported in Python itself! https://github.com/python/cpython/blob/893c9cc/Lib/_osx_support.py#L314-L328ARCHFLAGS: -arch x86_64@@ -339,7 +339,7 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-${{ matrix.compiler }}-ccache+ key: ${{ matrix.os }}-${{ matrix.compiler }}-ccache- name: Build pedalboard locallyenv:CCACHE_DIR: ${{ github.workspace }}/.ccache@@ -351,6 +351,7 @@ jobs:CCACHE_IGNOREOPTIONS: "-fno-strict-overflow -fwrapv -W* -arch x86_64 arm64 -dynamic -fno-common -g -I/usr/local/opt/*"CCACHE_LOGFILE: ${{ github.workspace }}/.ccache_logUSE_ASAN: "1"+ USE_PORTABLE_SIMD: "1" # Use portable SIMD to avoid "Illegal instruction" on different runner CPUsDISABLE_LTO: "1" # Speeds up un-cacheable link step which doesn't really increase performance in tests anywaysCC: ${{ matrix.cc }}CXX: ${{ matrix.cxx }}@@ -443,7 +444,7 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-${{ matrix.compiler }}-ccache+ key: ${{ matrix.os }}-${{ matrix.compiler }}-ccache- name: Print Restored ${{ runner.os }} Objectsrun: ls -lashR ${{ github.workspace }}# Without this, distutils will recompile the extension even though we already have the .so built:@@ -505,35 +506,35 @@ jobs:matrix:include:- {- os: macos-13,+ os: macos-15-intel,python-version: "3.10",compiler: "clang",cc: "ccache clang",cxx: "ccache clang++",}- {- os: macos-13,+ os: macos-15-intel,python-version: "3.11",compiler: "clang",cc: "ccache clang",cxx: "ccache clang++",}- {- os: macos-13,+ os: macos-15-intel,python-version: "3.12",compiler: "clang",cc: "ccache clang",cxx: "ccache clang++",}- {- os: macos-13,+ os: macos-15-intel,python-version: "3.13",compiler: "clang",cc: "ccache clang",cxx: "ccache clang++",}- {- os: macos-13,+ os: macos-15-intel,python-version: "3.14",compiler: "clang",cc: "ccache clang",@@ -672,7 +673,7 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-${{ matrix.compiler }}-ccache+ key: ${{ matrix.os }}-${{ matrix.compiler }}-ccache# Without this, distutils will recompile the extension even though we already have the shared object built:- name: Touch Restored ${{ runner.os }} Objects to Prevent Cache Missif: runner.os == 'Linux' || runner.os == 'macOS'@@ -694,7 +695,7 @@ jobs:CCACHE_DEBUG: "1"# Use the minimum macOS deployment target supported by our version of PyBind:MACOSX_DEPLOYMENT_TARGET: "10.14"- # This build caching is only to speed up tests on CI, so we only care about x86_64 for now.+ # This build caching is only to speed up tests on CI, so we only care about x86_64 (macos-15-intel runners).# Without limiting to a single architecture, ccache can't properly cache mixed Objective-C and C++ builds.# Fun fact: this is supported in Python itself! https://github.com/python/cpython/blob/893c9cc/Lib/_osx_support.py#L314-L328ARCHFLAGS: -arch x86_64@@ -786,11 +787,12 @@ jobs:${{ github.workspace }}/pedalboard/build/lib*${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/pedalboard/juce_overrides${{ github.workspace }}/pedalboard/build/temp${{ github.workspace }}/pedalboard/vendors- key: ${{ runner.os }}-clang-ccache+ key: ${{ matrix.os }}-clang-ccache- name: Build pedalboard locallyenv:DEBUG: "0"USE_ASAN: "1"+ USE_PORTABLE_SIMD: "1" # Use portable SIMD to avoid "Illegal instruction" on different runner CPUsCCACHE_DIR: ${{ github.workspace }}/.ccacheCCACHE_BASEDIR: ${{ github.workspace }}CCACHE_DEBUGDIR: ${{ github.workspace }}/.ccache_debug@@ -827,22 +829,22 @@ jobs:strategy:matrix:include:- - { os: macos-13, build: cp310-macosx_x86_64 }- - { os: macos-13, build: cp311-macosx_x86_64 }- - { os: macos-13, build: cp312-macosx_x86_64 }- - { os: macos-13, build: cp313-macosx_x86_64 }- - { os: macos-13, build: cp313t-macosx_x86_64 }+ - { os: macos-15-intel, build: cp310-macosx_x86_64 }+ - { os: macos-15-intel, build: cp311-macosx_x86_64 }+ - { os: macos-15-intel, build: cp312-macosx_x86_64 }+ - { os: macos-15-intel, build: cp313-macosx_x86_64 }+ - { os: macos-15-intel, build: cp313t-macosx_x86_64 }# Universal wheels are rarely used; only support them for Python 3.12:- - { os: macos-13, build: cp312-macosx_universal2 }- - { os: macos-13, build: cp310-macosx_arm64 }- - { os: macos-13, build: cp311-macosx_arm64 }- - { os: macos-13, build: cp312-macosx_arm64 }- - { os: macos-13, build: cp313-macosx_arm64 }- - { os: macos-13, build: cp313t-macosx_arm64 }- - { os: macos-13, build: cp314-macosx_arm64 }- - { os: macos-13, build: cp314t-macosx_arm64 }- # - { os: macos-13, build: pp38-macosx_x86_64 }- # - { os: macos-13, build: pp39-macosx_x86_64 }+ - { os: macos-15-intel, build: cp312-macosx_universal2 }+ - { os: macos-15-intel, build: cp310-macosx_arm64 }+ - { os: macos-15-intel, build: cp311-macosx_arm64 }+ - { os: macos-15-intel, build: cp312-macosx_arm64 }+ - { os: macos-15-intel, build: cp313-macosx_arm64 }+ - { os: macos-15-intel, build: cp313t-macosx_arm64 }+ - { os: macos-15-intel, build: cp314-macosx_arm64 }+ - { os: macos-15-intel, build: cp314t-macosx_arm64 }+ # - { os: macos-15-intel, build: pp38-macosx_x86_64 }+ # - { os: macos-15-intel, build: pp39-macosx_x86_64 }- { os: windows-latest, build: cp39-win_amd64 }- { os: windows-latest, build: cp310-win_amd64 }- { os: windows-latest, build: cp311-win_amd64 }diff --git a/CMakeLists.txt b/CMakeLists.txtindex 91dc0a8..5a21262 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -199,7 +199,14 @@ elseif(UNIX AND NOT APPLE)if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64")add_compile_definitions(HAVE_NEON=1)else()- add_compile_options(-march=native)+ # Use -march=native for local builds to optimize for the current CPU,+ # but use a portable baseline for CI builds to avoid "Illegal instruction" errors+ # when ccache restores objects built on different runner hardware.+ if(DEFINED ENV{USE_PORTABLE_SIMD})+ add_compile_options(-mavx)+ else()+ add_compile_options(-march=native)+ endif()add_compile_definitions(HAVE_AVX)endif()diff --git a/pedalboard/io/ReadableAudioFile.h b/pedalboard/io/ReadableAudioFile.hindex 8a1597d..db1e5a9 100644--- a/pedalboard/io/ReadableAudioFile.h+++ b/pedalboard/io/ReadableAudioFile.h@@ -277,12 +277,13 @@ public:long long numSamplesToKeep = numSamples;- py::buffer_info outputInfo = buffer.request();+ // Get the data pointer directly without keeping a buffer_info reference+ // that would prevent resizing later (needed for Python 3.14+ / NumPy 2.x)+ float *outputPtr = buffer.mutable_data();{py::gil_scoped_release release;- numSamplesToKeep =- readInternal(numChannels, numSamples, (float *)outputInfo.ptr);+ numSamplesToKeep = readInternal(numChannels, numSamples, outputPtr);// After this point, we no longer need to hold the read lock as we don't// interact with the reader object anymore. Releasing this early (beforediff --git a/setup.py b/setup.pyindex eb6e00e..b5536e5 100644--- a/setup.py+++ b/setup.py@@ -175,7 +175,13 @@ elif platform.system() == "Linux":else:# And on x86, ignore the ARM-specific SIMD code (and KCVI; not GCC or Clang compatible).fftw_paths = ignore_files_matching(fftw_paths, "neon")- ALL_CFLAGS.append("-march=native")+ # Use -march=native for local builds to optimize for the current CPU,+ # but use a portable baseline for CI builds to avoid "Illegal instruction" errors+ # when ccache restores objects built on different runner hardware.+ if os.getenv("USE_PORTABLE_SIMD"):+ ALL_CFLAGS.append("-mavx")+ else:+ ALL_CFLAGS.append("-march=native")# Enable SIMD instructions:ALL_CFLAGS.extend([