about summary refs log tree commit diff
path: root/pkgs/development/python-modules/samplerate/default.nix
blob: 7ac9950a6966888e67e2d93ff8564c8af05f000a (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
{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, cffi
, numpy
, libsamplerate
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "samplerate";
  version = "0.1.0";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "tuxu";
    repo = "python-samplerate";
    rev = "refs/tags/${version}";
    hash = "sha256-lHZ9SVnKcsEsnKYXR/QocGbKPEoA7yCZxXvrNPeH1rA=";
  };

  postPatch = ''
    substituteInPlace setup.py \
      --replace ", 'pytest-runner'" ""

    substituteInPlace samplerate/lowlevel.py --replace \
      "lib_filename = _find_library('samplerate')" \
      'lib_filename = "${libsamplerate.out}/lib/libsamplerate${stdenv.hostPlatform.extensions.sharedLibrary}"'
  '';

  propagatedBuildInputs = [
    cffi
    numpy
  ];

  pythonImportsCheck = [
    "samplerate"
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  preCheck = ''
    rm -rf samplerate
  '';

  meta = with lib; {
    description = "Python bindings for libsamplerate based on CFFI and NumPy";
    homepage = "https://github.com/tuxu/python-samplerate";
    changelog = "https://github.com/tuxu/python-samplerate/releases/tag/${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ hexa ];
  };
}