1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5
6# build-system
7, setuptools
8
9# runtime
10, audioread
11, decorator
12, joblib
13, lazy-loader
14, matplotlib
15, msgpack
16, numba
17, numpy
18, pooch
19, scikit-learn
20, scipy
21, soundfile
22, soxr
23, typing-extensions
24
25# tests
26, ffmpeg-headless
27, packaging
28, pytest-mpl
29, pytestCheckHook
30, resampy
31, samplerate
32}:
33
34buildPythonPackage rec {
35 pname = "librosa";
36 version = "0.10.1";
37 format = "pyproject";
38
39 src = fetchFromGitHub {
40 owner = "librosa";
41 repo = "librosa";
42 rev = "refs/tags/${version}";
43 fetchSubmodules = true; # for test data
44 hash = "sha256-zbmU87hI9A1CVcBZ/5FU8z0t6SS4jfJk9bj9kLe/EHI=";
45 };
46
47 nativeBuildInputs = [
48 setuptools
49 ];
50
51 patches = [
52 (fetchpatch {
53 # https://github.com/librosa/librosa/issues/1754
54 # https://github.com/librosa/librosa/pull/1755
55 name = "matplotlib-3.8-compat.patch";
56 url = "https://github.com/librosa/librosa/commit/beef47885ce1255b43b65e48ea2054ddace37c6c.patch";
57 hash = "sha256-rrnlUHXHY2me4BWGs3wFq8WJmz75CbXTWKFp3VdJKzE=";
58 })
59 ];
60
61 postPatch = ''
62 substituteInPlace setup.cfg \
63 --replace "--cov-report term-missing --cov librosa --cov-report=xml " ""
64 '';
65
66 propagatedBuildInputs = [
67 audioread
68 decorator
69 joblib
70 lazy-loader
71 msgpack
72 numba
73 numpy
74 pooch
75 scipy
76 scikit-learn
77 soundfile
78 soxr
79 typing-extensions
80 ];
81
82 passthru.optional-dependencies.matplotlib = [
83 matplotlib
84 ];
85
86 # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
87 pythonImportsCheck = [
88 "librosa"
89 ];
90
91 nativeCheckInputs = [
92 ffmpeg-headless
93 packaging
94 pytest-mpl
95 pytestCheckHook
96 resampy
97 samplerate
98 ] ++ passthru.optional-dependencies.matplotlib;
99
100 preCheck = ''
101 export HOME=$TMPDIR
102 '';
103
104 disabledTests = [
105 # requires network access
106 "test_example"
107 "test_example_info"
108 "test_load_resample"
109 ];
110
111 meta = with lib; {
112 description = "Python library for audio and music analysis";
113 homepage = "https://github.com/librosa/librosa";
114 changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
115 license = licenses.isc;
116 maintainers = with maintainers; [ GuillaumeDesforges ];
117 };
118
119}