diff --git a/pkgs/development/python-modules/sounddevice/default.nix b/pkgs/development/python-modules/sounddevice/default.nix index 6d467a57c604..5b8c4a46b2be 100644 --- a/pkgs/development/python-modules/sounddevice/default.nix +++ b/pkgs/development/python-modules/sounddevice/default.nix @@ -4,15 +4,16 @@ , cffi , numpy , portaudio +, substituteAll }: buildPythonPackage rec { pname = "sounddevice"; - version = "0.3.9"; + version = "0.3.11"; src = fetchPypi { inherit pname version; - sha256 = "1c9e833f8c8ccc67c0291c3448b29e9acc548fe56d15ee6f7fdd7037e00319f8"; + sha256 = "0pfcbgbl77nggchxb2i5rb78m7hpgn65aqpz99yfx1fgfbmy9yg1"; }; propagatedBuildInputs = [ cffi numpy portaudio ]; @@ -20,9 +21,12 @@ buildPythonPackage rec { # No tests included nor upstream available. doCheck = false; - prePatch = '' - substituteInPlace src/sounddevice.py --replace "'portaudio'" "'${portaudio}/lib/libportaudio.so.2'" - ''; + patches = [ + (substituteAll { + src = ./fix-portaudio-library-path.patch; + portaudio = "${portaudio}/lib/libportaudio.so.2"; + }) + ]; meta = { description = "Play and Record Sound with Python"; diff --git a/pkgs/development/python-modules/sounddevice/fix-portaudio-library-path.patch b/pkgs/development/python-modules/sounddevice/fix-portaudio-library-path.patch new file mode 100644 index 000000000000..5be786ee0f5c --- /dev/null +++ b/pkgs/development/python-modules/sounddevice/fix-portaudio-library-path.patch @@ -0,0 +1,34 @@ +diff --git a/sounddevice.py b/sounddevice.py +index f03476c..5745b6e 100644 +--- a/sounddevice.py ++++ b/sounddevice.py +@@ -58,28 +58,7 @@ from ctypes.util import find_library as _find_library + from _sounddevice import ffi as _ffi + + +-try: +- for _libname in ( +- 'portaudio', # Default name on POSIX systems +- 'bin\\libportaudio-2.dll', # DLL from conda-forge +- ): +- _libname = _find_library(_libname) +- if _libname is not None: +- break +- else: +- raise OSError('PortAudio library not found') +- _lib = _ffi.dlopen(_libname) +-except OSError: +- if _platform.system() == 'Darwin': +- _libname = 'libportaudio.dylib' +- elif _platform.system() == 'Windows': +- _libname = 'libportaudio' + _platform.architecture()[0] + '.dll' +- else: +- raise +- import _sounddevice_data +- _libname = _os.path.join( +- next(iter(_sounddevice_data.__path__)), 'portaudio-binaries', _libname) +- _lib = _ffi.dlopen(_libname) ++_lib = _ffi.dlopen('@portaudio@') + + _sampleformats = { + 'float32': _lib.paFloat32,