1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 cmake,
8 setuptools,
9
10 # nativeBuildInputs
11 autoAddDriverRunpath,
12 cudaPackages,
13
14 # dependencies
15 numpy,
16 scipy,
17}:
18
19buildPythonPackage {
20 pname = "gpu-rir";
21 version = "0-unstable-2025-01-20";
22 pyproject = true;
23
24 src = fetchFromGitHub {
25 owner = "DavidDiazGuerra";
26 repo = "gpuRIR";
27 rev = "fd8af43a4a113d3c2c05f0085a0119ecb1f1a484";
28 hash = "sha256-nYi91iaNb9gswYzXW7aNpD3yYIgMvTen9r02G4d6joo=";
29 };
30
31 # Inject cmakeFlags in the cmake call
32 postPatch = ''
33 substituteInPlace setup.py \
34 --replace-fail \
35 "cmake_args = [" \
36 "cmake_args = os.environ.get('cmakeFlags', \"\").split() + ["
37 '';
38
39 build-system = [
40 cmake
41 setuptools
42 ];
43 dontUseCmakeConfigure = true;
44
45 nativeBuildInputs = [
46 autoAddDriverRunpath
47 cudaPackages.cuda_nvcc
48 ];
49
50 # TODO: Investigate why (deprecated) FindCUDA fails to set these variables
51 cmakeFlags = [
52 (lib.cmakeFeature "CUDA_CUFFT_LIBARIES" "${lib.getLib cudaPackages.libcufft}/lib/libcufft.so")
53 (lib.cmakeFeature "CUDA_curand_LIBRARY" "${lib.getLib cudaPackages.libcurand}/lib/libcurand.so")
54 ];
55
56 buildInputs = with cudaPackages; [
57 cuda_cccl # <nv/target>
58 cuda_cudart # cuda_runtime.h
59 libcufft
60 libcurand
61 ];
62
63 dependencies = [
64 numpy
65 scipy
66 ];
67
68 pythonImportsCheck = [ "gpuRIR" ];
69 # Fails at import because there is no GPU access in the sandbox:
70 # Check whether the following modules can be imported: gpuRIR
71 # GPUassert: CUDA driver version is insufficient for CUDA runtime version /build/source/src/gpuRIR_cuda.cu 1037
72 dontUsePythonImportsCheck = true;
73
74 # No tests
75 doCheck = false;
76
77 meta = {
78 description = "Python library for Room Impulse Response (RIR) simulation with GPU acceleration";
79 homepage = "https://github.com/DavidDiazGuerra/gpuRIR";
80 license = lib.licenses.agpl3Only;
81 maintainers = with lib.maintainers; [ GaetanLepage ];
82 };
83}