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.0";
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-MXzPIcbG8b1JwhEyAZG4DRObGaHq+ipVHMrZCzaxLdE=";
45 };
46
47 patches = [
48 # https://github.com/librosa/librosa/pull/1731
49 (fetchpatch {
50 name = "support-scipy-1.11.patch";
51 url = "https://github.com/librosa/librosa/commit/12dee8eabed7df14c5622b52c05393ddfeb11f4b.patch";
52 hash = "sha256-JxTXU0Mc+QYpsafjoGLaIccD7EdCYJvIVianeosYpw4=";
53 })
54 ];
55
56 nativeBuildInputs = [
57 setuptools
58 ];
59
60 postPatch = ''
61 substituteInPlace setup.cfg \
62 --replace "--cov-report term-missing --cov librosa --cov-report=xml " ""
63 '';
64
65 propagatedBuildInputs = [
66 audioread
67 decorator
68 joblib
69 lazy-loader
70 msgpack
71 numba
72 numpy
73 pooch
74 scipy
75 scikit-learn
76 soundfile
77 soxr
78 typing-extensions
79 ];
80
81 passthru.optional-dependencies.matplotlib = [
82 matplotlib
83 ];
84
85 # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
86 pythonImportsCheck = [
87 "librosa"
88 ];
89
90 nativeCheckInputs = [
91 ffmpeg-headless
92 packaging
93 pytest-mpl
94 pytestCheckHook
95 resampy
96 samplerate
97 ] ++ passthru.optional-dependencies.matplotlib;
98
99 preCheck = ''
100 export HOME=$TMPDIR
101 '';
102
103 disabledTests = [
104 # requires network access
105 "test_example"
106 "test_example_info"
107 "test_load_resample"
108 ];
109
110 meta = with lib; {
111 description = "Python library for audio and music analysis";
112 homepage = "https://github.com/librosa/librosa";
113 changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
114 license = licenses.isc;
115 maintainers = with maintainers; [ GuillaumeDesforges ];
116 };
117
118}