linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / galario / default.nix
blob4e28f84bacdb25bb01fb29c31795dce99945a1b9
1 { lib, stdenv
2 , fetchzip
3 , fetchFromGitHub
4 , cmake
5 , fftw
6 , fftwFloat
7 , enablePython ? false
8 , pythonPackages ? null
9 , llvmPackages
11 let
12   # CMake recipes are needed to build galario
13   # Build process would usually download them
14   great-cmake-cookoff = fetchzip {
15     url = "https://github.com/UCL/GreatCMakeCookOff/archive/v2.1.9.tar.gz";
16     sha256 = "1yd53b5gx38g6f44jmjk4lc4igs3p25z6616hfb7aq79ly01q0w2";
17   };
19 stdenv.mkDerivation rec {
20   pname = "galario";
21   version = "1.2.2";
23   src = fetchFromGitHub {
24     owner = "mtazzari";
25     repo = pname;
26     rev = "v${version}";
27     sha256 = "0dw88ga50x3jwyfgcarn4azlhiarggvdg262hilm7rbrvlpyvha0";
28   };
30   nativeBuildInputs = [ cmake ];
32   buildInputs = [ fftw fftwFloat ]
33   ++ lib.optional enablePython pythonPackages.python
34   ++ lib.optional stdenv.isDarwin llvmPackages.openmp
35   ;
37   propagatedBuildInputs = lib.optional enablePython [
38     pythonPackages.numpy
39     pythonPackages.cython
40     pythonPackages.pytest
41   ];
43   checkInputs = lib.optional enablePython [ pythonPackages.scipy pythonPackages.pytestcov ];
45   preConfigure = ''
46     mkdir -p build/external/src
47     cp -r ${great-cmake-cookoff} build/external/src/GreatCMakeCookOff
48     chmod -R 777 build/external/src/GreatCMakeCookOff
49   '';
51   preCheck = ''
52     ${if stdenv.isDarwin then "export DYLD_LIBRARY_PATH=$(pwd)/src/" else "export LD_LIBRARY_PATH=$(pwd)/src/"}
53     ${if enablePython then "sed -i -e 's|^#!.*|#!${stdenv.shell}|' python/py.test.sh" else ""}
54   '';
56   doCheck = true;
58   postInstall = lib.optionalString (stdenv.isDarwin && enablePython) ''
59     install_name_tool -change libgalario.dylib $out/lib/libgalario.dylib $out/lib/python*/site-packages/galario/double/libcommon.so
60     install_name_tool -change libgalario_single.dylib $out/lib/libgalario_single.dylib $out/lib/python*/site-packages/galario/single/libcommon.so
61   '';
63   meta = with lib; {
64     description = "GPU Accelerated Library for Analysing Radio Interferometer Observations";
65     longDescription = ''
66       Galario is a library that exploits the computing power of modern
67       graphic cards (GPUs) to accelerate the comparison of model
68       predictions to radio interferometer observations. Namely, it
69       speeds up the computation of the synthetic visibilities given a
70       model image (or an axisymmetric brightness profile) and their
71       comparison to the observations.
72     '';
73     homepage = "https://mtazzari.github.io/galario/";
74     license = licenses.lgpl3;
75     maintainers = [ maintainers.smaret ];
76     platforms = platforms.all;
77   };