1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, cffi
6, numpy
7, libsamplerate
8, pytestCheckHook
9}:
10
11buildPythonPackage rec {
12 pname = "samplerate";
13 version = "0.1.0";
14 format = "setuptools";
15
16 src = fetchFromGitHub {
17 owner = "tuxu";
18 repo = "python-samplerate";
19 rev = "refs/tags/${version}";
20 hash = "sha256-lHZ9SVnKcsEsnKYXR/QocGbKPEoA7yCZxXvrNPeH1rA=";
21 };
22
23 postPatch = ''
24 substituteInPlace setup.py \
25 --replace ", 'pytest-runner'" ""
26
27 substituteInPlace samplerate/lowlevel.py --replace \
28 "lib_filename = _find_library('samplerate')" \
29 'lib_filename = "${libsamplerate.out}/lib/libsamplerate${stdenv.hostPlatform.extensions.sharedLibrary}"'
30 '';
31
32 propagatedBuildInputs = [
33 cffi
34 numpy
35 ];
36
37 pythonImportsCheck = [
38 "samplerate"
39 ];
40
41 nativeCheckInputs = [
42 pytestCheckHook
43 ];
44
45 preCheck = ''
46 rm -rf samplerate
47 '';
48
49 meta = with lib; {
50 description = "Python bindings for libsamplerate based on CFFI and NumPy";
51 homepage = "https://github.com/tuxu/python-samplerate";
52 changelog = "https://github.com/tuxu/python-samplerate/releases/tag/${version}";
53 license = licenses.mit;
54 maintainers = with maintainers; [ hexa ];
55 };
56}