1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # runtime
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 typing-extensions,
25
26 # tests
27 ffmpeg-headless,
28 packaging,
29 pytest-mpl,
30 pytestCheckHook,
31 resampy,
32 samplerate,
33}:
34
35buildPythonPackage rec {
36 pname = "librosa";
37 version = "0.10.2";
38 format = "pyproject";
39
40 src = fetchFromGitHub {
41 owner = "librosa";
42 repo = "librosa";
43 rev = "refs/tags/${version}";
44 fetchSubmodules = true; # for test data
45 hash = "sha256-zUKljPKWOhyb3Zv4KEUcvLsVkxVhL+rzErKycAl6jIg=";
46 };
47
48 nativeBuildInputs = [ setuptools ];
49
50 postPatch = ''
51 substituteInPlace setup.cfg \
52 --replace-fail "--cov-report term-missing --cov librosa --cov-report=xml " ""
53 '';
54
55 propagatedBuildInputs = [
56 audioread
57 decorator
58 joblib
59 lazy-loader
60 msgpack
61 numba
62 numpy
63 pooch
64 scipy
65 scikit-learn
66 soundfile
67 soxr
68 typing-extensions
69 ];
70
71 passthru.optional-dependencies.matplotlib = [ matplotlib ];
72
73 # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
74 pythonImportsCheck = [ "librosa" ];
75
76 nativeCheckInputs = [
77 ffmpeg-headless
78 packaging
79 pytest-mpl
80 pytestCheckHook
81 resampy
82 samplerate
83 ] ++ passthru.optional-dependencies.matplotlib;
84
85 preCheck = ''
86 export HOME=$TMPDIR
87 '';
88
89 disabledTests =
90 [
91 # requires network access
92 "test_example"
93 "test_example_info"
94 "test_load_resample"
95 "test_cite_released"
96 "test_cite_badversion"
97 "test_cite_unreleased"
98 ]
99 ++ lib.optionals stdenv.isDarwin [
100 # crashing the python interpreter
101 "test_unknown_time_unit"
102 "test_unknown_wavaxis"
103 "test_waveshow_unknown_wavaxis"
104 "test_waveshow_bad_maxpoints"
105 "test_waveshow_deladaptor"
106 "test_waveshow_disconnect"
107 "test_unknown_axis"
108 "test_axis_bound_warning"
109 "test_auto_aspect"
110 ];
111
112 meta = with lib; {
113 description = "Python library for audio and music analysis";
114 homepage = "https://github.com/librosa/librosa";
115 changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
116 license = licenses.isc;
117 maintainers = with maintainers; [ GuillaumeDesforges ];
118 };
119}