nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.3";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "tuxu";
30 repo = "python-samplerate";
31 tag = "v${version}";
32 hash = "sha256-7FAdIqsYCapmEAYiAuoS5m/jFExXZX3hn3kwxn9NWEc=";
33 };
34
35 patches = [
36 # https://github.com/tuxu/python-samplerate/pull/33
37 ./numpy-2.4-compat.patch
38 ];
39
40 postPatch = ''
41 # unvendor pybind11, libsamplerate
42 rm -r external
43 substituteInPlace CMakeLists.txt \
44 --replace-fail "add_subdirectory(external)" "find_package(pybind11 REQUIRED)"
45 '';
46
47 build-system = [
48 cmake
49 setuptools
50 setuptools-scm
51 pybind11
52 ];
53
54 dontUseCmakeConfigure = true;
55
56 buildInputs = [ libsamplerate ];
57
58 propagatedBuildInputs = [
59 cffi
60 numpy
61 ];
62
63 pythonImportsCheck = [ "samplerate" ];
64
65 nativeCheckInputs = [ pytestCheckHook ];
66
67 preCheck = ''
68 rm -rf samplerate
69 '';
70
71 meta = {
72 description = "Python bindings for libsamplerate based on CFFI and NumPy";
73 homepage = "https://github.com/tuxu/python-samplerate";
74 changelog = "https://github.com/tuxu/python-samplerate/releases/tag/${src.tag}";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ hexa ];
77 };
78}