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 build-system = [ setuptools ];
53
54 dependencies = [
55 audioread
56 decorator
57 joblib
58 lazy-loader
59 msgpack
60 numba
61 numpy
62 pooch
63 scikit-learn
64 scipy
65 soundfile
66 soxr
67 standard-aifc
68 standard-sunau
69 typing-extensions
70 ];
71
72 optional-dependencies.matplotlib = [ matplotlib ];
73
74 # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
75 pythonImportsCheck = [ "librosa" ];
76
77 nativeCheckInputs = [
78 ffmpeg-headless
79 packaging
80 pytest-cov-stub
81 pytest-mpl
82 pytestCheckHook
83 resampy
84 samplerate
85 writableTmpDirAsHomeHook
86 ] ++ optional-dependencies.matplotlib;
87
88 disabledTests =
89 [
90 # requires network access
91 "test_example"
92 "test_example_info"
93 "test_load_resample"
94 "test_cite_released"
95 "test_cite_badversion"
96 "test_cite_unreleased"
97 ]
98 ++ lib.optionals stdenv.hostPlatform.isDarwin [
99 # crashing the python interpreter
100 "test_unknown_time_unit"
101 "test_unknown_wavaxis"
102 "test_waveshow_unknown_wavaxis"
103 "test_waveshow_bad_maxpoints"
104 "test_waveshow_deladaptor"
105 "test_waveshow_disconnect"
106 "test_unknown_axis"
107 "test_axis_bound_warning"
108 "test_auto_aspect"
109 ]
110 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
111 # Flaky (numerical comparison fails)
112 "test_istft_multi"
113 "test_pitch_shift_multi"
114 "test_time_stretch_multi"
115 ];
116
117 meta = {
118 description = "Python library for audio and music analysis";
119 homepage = "https://github.com/librosa/librosa";
120 changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
121 license = lib.licenses.isc;
122 maintainers = with lib.maintainers; [ GuillaumeDesforges ];
123 };
124}