From b90e85e10afbc3a73b80ce2f4569d2ac0a334010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 10 Jul 2026 19:16:49 +0200 Subject: [PATCH] python314Packages.samplerate-ledfx: fix Python 3.14 support --- .../samplerate-ledfx/default.nix | 10 +++-- .../fix-python3.14-support.diff | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/python-modules/samplerate-ledfx/fix-python3.14-support.diff diff --git a/pkgs/development/python-modules/samplerate-ledfx/default.nix b/pkgs/development/python-modules/samplerate-ledfx/default.nix index cd95073ca359..cb6fc5443fcb 100644 --- a/pkgs/development/python-modules/samplerate-ledfx/default.nix +++ b/pkgs/development/python-modules/samplerate-ledfx/default.nix @@ -3,12 +3,12 @@ buildPythonPackage, cmake, fetchFromGitHub, + fetchpatch, libsamplerate, numpy, pybind11, pytest-asyncio, pytestCheckHook, - pythonAtLeast, setuptools, setuptools-scm, }: @@ -18,8 +18,6 @@ buildPythonPackage (finalAttrs: { version = "0.2.6"; pyproject = true; - disabled = pythonAtLeast "3.14"; - src = fetchFromGitHub { owner = "LedFx"; repo = "python-samplerate-ledfx"; @@ -27,6 +25,12 @@ buildPythonPackage (finalAttrs: { hash = "sha256-SLmaWSq/Ou23BfdWKlzE9gIfORgF9skUVEw1Tzpd5b4="; }; + patches = [ + # Fix Python 3.14 support based on https://github.com/tuxu/python-samplerate/commit/06e88d1a869db30ce9037498f4dec2f74601d127 + # but with fixes that it applies + ./fix-python3.14-support.diff + ]; + # unvendor pybind11, libsamplerate postPatch = '' rm -r external diff --git a/pkgs/development/python-modules/samplerate-ledfx/fix-python3.14-support.diff b/pkgs/development/python-modules/samplerate-ledfx/fix-python3.14-support.diff new file mode 100644 index 000000000000..089fbabff7b7 --- /dev/null +++ b/pkgs/development/python-modules/samplerate-ledfx/fix-python3.14-support.diff @@ -0,0 +1,38 @@ +diff --git a/src/samplerate.cpp b/src/samplerate.cpp +index f0eba25..04f16fd 100644 +--- a/src/samplerate.cpp ++++ b/src/samplerate.cpp +@@ -268,7 +268,9 @@ class Resampler { + // create a shorter view of the array + if ((size_t)output_frames_gen < new_size) { + out_shape[0] = output_frames_gen; +- output.resize(out_shape); ++ return py::array_t( ++ out_shape, outbuf.strides, static_cast(outbuf.ptr), ++ output); + } else if ((size_t)output_frames_gen >= new_size) { + // This means our fudge factor is too small. + throw std::runtime_error("Generated more output samples than expected!"); +@@ -434,7 +436,10 @@ class CallbackResampler { + // create a shorter view of the array + if (output_frames_gen < frames) { + out_shape[0] = output_frames_gen; +- output.resize(out_shape); ++ auto strides = std::vector(output.strides(), ++ output.strides() + output.ndim()); ++ return py::array_t( ++ out_shape, strides, static_cast(outbuf.ptr), output); + } + + return output; +@@ -561,7 +566,9 @@ py::array_t resample( + // create a shorter view of the array + if ((size_t)output_frames_gen < new_size) { + out_shape[0] = output_frames_gen; +- output.resize(out_shape); ++ auto base = output; ++ output = py::array_t( ++ out_shape, outbuf.strides, static_cast(outbuf.ptr), base); + } else if ((size_t)output_frames_gen >= new_size) { + // This means our fudge factor is too small. + throw std::runtime_error("Generated more output samples than expected!");