@@ -1,7 +1,8 @@
11{ lib
22, buildPythonPackage
33, fetchPypi
4−, pytest
4+, fetchpatch
5+, pytestCheckHook
56, numpy
67, libsndfile
78, cffi
@@ -12,6 +13,8 @@
1213buildPythonPackage rec {
1314 pname = "soundfile";
1415 version = "0.10.3.post1";
16+ # https://github.com/bastibe/python-soundfile/issues/157
17+ disabled = isPyPy || stdenv.isi686;
1518
1619 src = fetchPypi {
1720 pname = "SoundFile";
@@ -19,22 +22,30 @@ buildPythonPackage rec {
1922 sha256 = "0yqhrfz7xkvqrwdxdx2ydy4h467sk7z3gf984y1x2cq7cm1gy329";
2023 };
2124
22− checkInputs = [ pytest ];
23− propagatedBuildInputs = [ numpy libsndfile cffi ];
24− propagatedNativeBuildInputs = [ cffi ];
25+ patches = [
26+ # Fix build on macOS arm64, https://github.com/bastibe/python-soundfile/pull/332
27+ (fetchpatch {
28+ url = "https://github.com/bastibe/python-soundfile/commit/e554e9ce8bed96207d587e6aa661e4b08f1c6a79.patch";
29+ sha256 = "sha256-vu/7s5q4I3yBnoNHmmFmcXvOLFcPwY9ri9ri6cKLDwU=";
30+ })
31+ ];
2532
26− meta = {
27− description = "An audio library based on libsndfile, CFFI and NumPy";
28− license = lib.licenses.bsd3;
29− homepage = "https://github.com/bastibe/PySoundFile";
30− maintainers = with lib.maintainers; [ fridh ];
31− };
33+ postPatch = ''
34+ substituteInPlace soundfile.py --replace "_find_library('sndfile')" "'${libsndfile.out}/lib/libsndfile${stdenv.hostPlatform.extensions.sharedLibrary}'"
35+ '';
3236
33− postPatch = ''
34− substituteInPlace soundfile.py --replace "_find_library('sndfile')" "'${libsndfile.out}/lib/libsndfile${stdenv.hostPlatform.extensions.sharedLibrary}'"
35− '';
37+ checkInputs = [ pytestCheckHook ];
38+ propagatedBuildInputs = [ numpy libsndfile cffi ];
39+ propagatedNativeBuildInputs = [ cffi ];
3640
37− # https://github.com/bastibe/PySoundFile/issues/157
38− disabled = isPyPy || stdenv.isi686;
41+ # Test fails on aarch64-darwin with `MemoryError`, 53 failed, 31 errors, see
42+ # https://github.com/bastibe/python-soundfile/issues/331
43+ doCheck = stdenv.system != "aarch64-darwin";
3944
45+ meta = {
46+ description = "An audio library based on libsndfile, CFFI and NumPy";
47+ license = lib.licenses.bsd3;
48+ homepage = "https://github.com/bastibe/python-soundfile";
49+ maintainers = with lib.maintainers; [ fridh ];
50+ };
4051}