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