about summary refs log tree commit diff
path: root/pkgs/development/python-modules/librosa/default.nix
blob: 62d712aa7b1f3d4e48391677ca181f9878fd576b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, fetchpatch

# build-system
, setuptools

# runtime
, audioread
, decorator
, joblib
, lazy-loader
, matplotlib
, msgpack
, numba
, numpy
, pooch
, scikit-learn
, scipy
, soundfile
, soxr
, typing-extensions

# tests
, ffmpeg-headless
, packaging
, pytest-mpl
, pytestCheckHook
, resampy
, samplerate
}:

buildPythonPackage rec {
  pname = "librosa";
  version = "0.10.1";
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "librosa";
    repo = "librosa";
    rev = "refs/tags/${version}";
    fetchSubmodules = true; # for test data
    hash = "sha256-zbmU87hI9A1CVcBZ/5FU8z0t6SS4jfJk9bj9kLe/EHI=";
  };

  nativeBuildInputs = [
    setuptools
  ];

  patches = [
    (fetchpatch {
      # https://github.com/librosa/librosa/issues/1754
      # https://github.com/librosa/librosa/pull/1755
      name = "matplotlib-3.8-compat.patch";
      url = "https://github.com/librosa/librosa/commit/beef47885ce1255b43b65e48ea2054ddace37c6c.patch";
      hash = "sha256-rrnlUHXHY2me4BWGs3wFq8WJmz75CbXTWKFp3VdJKzE=";
    })
  ];

  postPatch = ''
    substituteInPlace setup.cfg \
      --replace "--cov-report term-missing --cov librosa --cov-report=xml " ""
  '';

  propagatedBuildInputs = [
    audioread
    decorator
    joblib
    lazy-loader
    msgpack
    numba
    numpy
    pooch
    scipy
    scikit-learn
    soundfile
    soxr
    typing-extensions
  ];

  passthru.optional-dependencies.matplotlib = [
    matplotlib
  ];

  # check that import works, this allows to capture errors like https://github.com/librosa/librosa/issues/1160
  pythonImportsCheck = [
    "librosa"
  ];

  nativeCheckInputs = [
    ffmpeg-headless
    packaging
    pytest-mpl
    pytestCheckHook
    resampy
    samplerate
  ] ++ passthru.optional-dependencies.matplotlib;

  preCheck = ''
    export HOME=$TMPDIR
  '';

  disabledTests = [
    # requires network access
    "test_example"
    "test_example_info"
    "test_load_resample"
    # does not converge
    "test_nnls_vector"
  ] ++ lib.optionals stdenv.isDarwin [
    # https://github.com/librosa/librosa/pull/1808
    "test_pyin_multi_center"
  ];

  meta = with lib; {
    description = "Python library for audio and music analysis";
    homepage = "https://github.com/librosa/librosa";
    changelog = "https://github.com/librosa/librosa/releases/tag/${version}";
    license = licenses.isc;
    maintainers = with maintainers; [ GuillaumeDesforges ];
  };

}