summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/gpu-rir/default.nix
blob: a1d0fda616d2578c2509d648ac8121d6b600f027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  cmake,
  setuptools,

  # nativeBuildInputs
  autoAddDriverRunpath,
  cudaPackages,

  # dependencies
  numpy,
  scipy,
}:

buildPythonPackage {
  pname = "gpu-rir";
  version = "0-unstable-2025-01-20";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "DavidDiazGuerra";
    repo = "gpuRIR";
    rev = "fd8af43a4a113d3c2c05f0085a0119ecb1f1a484";
    hash = "sha256-nYi91iaNb9gswYzXW7aNpD3yYIgMvTen9r02G4d6joo=";
  };

  # Inject cmakeFlags in the cmake call
  postPatch = ''
    substituteInPlace setup.py \
      --replace-fail \
        "cmake_args = [" \
        "cmake_args = os.environ.get('cmakeFlags', \"\").split() + ["
  '';

  build-system = [
    cmake
    setuptools
  ];
  dontUseCmakeConfigure = true;

  nativeBuildInputs = [
    autoAddDriverRunpath
    cudaPackages.cuda_nvcc
  ];

  # TODO: Investigate why (deprecated) FindCUDA fails to set these variables
  cmakeFlags = [
    (lib.cmakeFeature "CUDA_CUFFT_LIBARIES" "${lib.getLib cudaPackages.libcufft}/lib/libcufft.so")
    (lib.cmakeFeature "CUDA_curand_LIBRARY" "${lib.getLib cudaPackages.libcurand}/lib/libcurand.so")
  ];

  buildInputs = with cudaPackages; [
    cuda_cccl # <nv/target>
    cuda_cudart # cuda_runtime.h
    libcufft
    libcurand
  ];

  dependencies = [
    numpy
    scipy
  ];

  pythonImportsCheck = [ "gpuRIR" ];
  # Fails at import because there is no GPU access in the sandbox:
  # Check whether the following modules can be imported: gpuRIR
  # GPUassert: CUDA driver version is insufficient for CUDA runtime version /build/source/src/gpuRIR_cuda.cu 1037
  dontUsePythonImportsCheck = true;

  # No tests
  doCheck = false;

  meta = {
    description = "Python library for Room Impulse Response (RIR) simulation with GPU acceleration";
    homepage = "https://github.com/DavidDiazGuerra/gpuRIR";
    license = lib.licenses.agpl3Only;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
}