pythonpackages.sounddevice: 0.3.9 -> 0.3.11 and fix for portaudio library path (#43083)

This commit is contained in:
Jos van Bakel 2018-07-07 18:46:06 +02:00 committed by Robert Schütz
parent 059f5fd8a8
commit 9291a3c0cf
2 changed files with 43 additions and 5 deletions

View File

@ -4,15 +4,16 @@
, cffi , cffi
, numpy , numpy
, portaudio , portaudio
, substituteAll
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "sounddevice"; pname = "sounddevice";
version = "0.3.9"; version = "0.3.11";
src = fetchPypi { src = fetchPypi {
inherit pname version; inherit pname version;
sha256 = "1c9e833f8c8ccc67c0291c3448b29e9acc548fe56d15ee6f7fdd7037e00319f8"; sha256 = "0pfcbgbl77nggchxb2i5rb78m7hpgn65aqpz99yfx1fgfbmy9yg1";
}; };
propagatedBuildInputs = [ cffi numpy portaudio ]; propagatedBuildInputs = [ cffi numpy portaudio ];
@ -20,9 +21,12 @@ buildPythonPackage rec {
# No tests included nor upstream available. # No tests included nor upstream available.
doCheck = false; doCheck = false;
prePatch = '' patches = [
substituteInPlace src/sounddevice.py --replace "'portaudio'" "'${portaudio}/lib/libportaudio.so.2'" (substituteAll {
''; src = ./fix-portaudio-library-path.patch;
portaudio = "${portaudio}/lib/libportaudio.so.2";
})
];
meta = { meta = {
description = "Play and Record Sound with Python"; description = "Play and Record Sound with Python";

View File

@ -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,