1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 cmake,
9 setuptools,
10 setuptools-scm,
11 pybind11,
12
13 # dependencies
14 cffi,
15 numpy,
16
17 # native dependencies
18 libsamplerate,
19
20 # tests
21 pytestCheckHook,
22}:
23
24buildPythonPackage rec {
25 pname = "samplerate";
26 version = "0.2.1";
27 pyproject = true;
28
29 src = fetchFromGitHub {
30 owner = "tuxu";
31 repo = "python-samplerate";
32 rev = "refs/tags/v${version}";
33 hash = "sha256-/9NFJcn8R0DFjVhFAIYOtzZM90hjVIfsVXFlS0nHNhA=";
34 };
35
36 postPatch = ''
37 # unvendor pybind11, libsamplerate
38 rm -r external
39 substituteInPlace CMakeLists.txt \
40 --replace-fail "add_subdirectory(external)" "find_package(pybind11 REQUIRED)"
41 '';
42
43 build-system = [
44 cmake
45 setuptools
46 setuptools-scm
47 pybind11
48 ];
49
50 dontUseCmakeConfigure = true;
51
52 buildInputs = [ libsamplerate ];
53
54 propagatedBuildInputs = [
55 cffi
56 numpy
57 ];
58
59 pythonImportsCheck = [ "samplerate" ];
60
61 nativeCheckInputs = [ pytestCheckHook ];
62
63 preCheck = ''
64 rm -rf samplerate
65 '';
66
67 meta = with lib; {
68 description = "Python bindings for libsamplerate based on CFFI and NumPy";
69 homepage = "https://github.com/tuxu/python-samplerate";
70 changelog = "https://github.com/tuxu/python-samplerate/releases/tag/${version}";
71 license = licenses.mit;
72 maintainers = with maintainers; [ hexa ];
73 };
74}