summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/librosa/default.nix
blob: 569d6c6902f1a03e712e0e84a6b95ff625de165b (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

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

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

buildPythonPackage rec {
  pname = "librosa";
  version = "0.11.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "librosa";
    repo = "librosa";
    tag = version;
    fetchSubmodules = true; # for test data
    hash = "sha256-T58J/Gi3tHzelr4enbYJi1KmO46QxE5Zlhkc0+EgvRg=";
  };

  patches = [
    # <https://github.com/librosa/librosa/pull/1977>
    ./fix-with-numba-0.62.0.patch
  ];

  build-system = [ setuptools ];

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

  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-cov-stub
    pytest-mpl
    pytestCheckHook
    resampy
    samplerate
    writableTmpDirAsHomeHook
  ]
  ++ optional-dependencies.matplotlib;

  disabledTests = [
    # requires network access
    "test_example"
    "test_example_info"
    "test_load_resample"
    "test_cite_released"
    "test_cite_badversion"
    "test_cite_unreleased"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # crashing the python interpreter
    "test_unknown_time_unit"
    "test_unknown_wavaxis"
    "test_waveshow_unknown_wavaxis"
    "test_waveshow_bad_maxpoints"
    "test_waveshow_deladaptor"
    "test_waveshow_disconnect"
    "test_unknown_axis"
    "test_axis_bound_warning"
    "test_auto_aspect"
  ]
  ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
    # AssertionError (numerical comparison fails)
    "test_beat_track_multi"
    "test_beat_track_multi_bpm_vector"
    "test_melspectrogram_multi"
    "test_melspectrogram_multi_time"
    "test_nnls_matrix"
    "test_nnls_multiblock"
    "test_onset_detect"
  ]
  ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
    # Flaky (numerical comparison fails)
    "test_istft_multi"
    "test_pitch_shift_multi"
    "test_time_stretch_multi"
  ];

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