1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 audioread,
12 decorator,
13 joblib,
14 lazy-loader,
15 matplotlib,
16 msgpack,
17 numba,
18 numpy,
19 pooch,
20 scikit-learn,
21 scipy,
22 soundfile,
23 soxr,
24 standard-aifc,
25 standard-sunau,
26 typing-extensions,
27
28 # tests
29 ffmpeg-headless,
30 packaging,
31 pytest-cov-stub,
32 pytest-mpl,
33 pytestCheckHook,
34 resampy,
35 samplerate,
36 writableTmpDirAsHomeHook,
37}:
38
39buildPythonPackage rec {
40 pname = "librosa";
41 version = "0.11.0";
42 pyproject = true;
43
44 src = fetchFromGitHub {
45 owner = "librosa";
46 repo = "librosa";
47 tag = version;
48 fetchSubmodules = true; # for test data
49 hash = "sha256-T58J/Gi3tHzelr4enbYJi1KmO46QxE5Zlhkc0+EgvRg=";
50 };
51
52 patches = [
53 # <https://github.com/librosa/librosa/pull/1977>
54 ./fix-with-numba-0.62.0.patch
55 ];
56
57 build-system = [ setuptools ];
58
59 dependencies = [
60 audioread
61 decorator
62 joblib
63 lazy-loader
64 msgpack
65 numba
66 numpy
67 pooch
68 scikit-learn
69 scipy
70 soundfile
71 soxr
72 standard-aifc
73 standard-sunau
74 typing-extensions
75 ];
76
77 optional-dependencies.matplotlib = [ matplotlib ];
78
79 # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
80 pythonImportsCheck = [ "librosa" ];
81
82 nativeCheckInputs = [
83 ffmpeg-headless
84 packaging
85 pytest-cov-stub
86 pytest-mpl
87 pytestCheckHook
88 resampy
89 samplerate
90 writableTmpDirAsHomeHook
91 ]
92 ++ optional-dependencies.matplotlib;
93
94 disabledTests = [
95 # requires network access
96 "test_example"
97 "test_example_info"
98 "test_load_resample"
99 "test_cite_released"
100 "test_cite_badversion"
101 "test_cite_unreleased"
102 ]
103 ++ lib.optionals stdenv.hostPlatform.isDarwin [
104 # crashing the python interpreter
105 "test_unknown_time_unit"
106 "test_unknown_wavaxis"
107 "test_waveshow_unknown_wavaxis"
108 "test_waveshow_bad_maxpoints"
109 "test_waveshow_deladaptor"
110 "test_waveshow_disconnect"
111 "test_unknown_axis"
112 "test_axis_bound_warning"
113 "test_auto_aspect"
114 ]
115 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
116 # AssertionError (numerical comparison fails)
117 "test_beat_track_multi"
118 "test_beat_track_multi_bpm_vector"
119 "test_melspectrogram_multi"
120 "test_melspectrogram_multi_time"
121 "test_nnls_matrix"
122 "test_nnls_multiblock"
123 "test_onset_detect"
124 ]
125 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
126 # Flaky (numerical comparison fails)
127 "test_istft_multi"
128 "test_pitch_shift_multi"
129 "test_time_stretch_multi"
130 ];
131
132 meta = {
133 description = "Python library for audio and music analysis";
134 homepage = "https://github.com/librosa/librosa";
135 changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
136 license = lib.licenses.isc;
137 maintainers = with lib.maintainers; [ carlthome ];
138 };
139}