1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, cmake
6, cython
7, numpy
8, six
9, nose
10, Mako
11, python
12, cudaSupport ? false, cudatoolkit
13, openclSupport ? true, ocl-icd, clblas
14}:
15
16buildPythonPackage rec {
17 pname = "libgpuarray";
18 version = "0.7.5";
19 name = pname + "-" + version;
20
21 src = fetchFromGitHub {
22 owner = "Theano";
23 repo = "libgpuarray";
24 rev = "v${version}";
25 sha256 = "0zkdwjq3k6ciiyf8y5w663fbsnmzhgy27yvpxfhkpxazw9vg3l5v";
26 };
27
28 # requires a GPU
29 doCheck = false;
30
31 configurePhase = "cmakeConfigurePhase";
32
33 libraryPath = lib.makeLibraryPath (
34 []
35 ++ lib.optionals cudaSupport [ cudatoolkit.lib cudatoolkit.out ]
36 ++ lib.optionals openclSupport [ ocl-icd clblas ]
37 );
38
39 preBuild = ''
40 make -j$NIX_BUILD_CORES
41 make install
42
43 export NIX_CFLAGS_COMPILE="-L $out/lib -I $out/include $NIX_CFLAGS_COMPILE"
44
45 cd ..
46 '';
47
48 postFixup = ''
49 rm $out/lib/libgpuarray-static.a
50
51 function fixRunPath {
52 p=$(patchelf --print-rpath $1)
53 patchelf --set-rpath "$p:$libraryPath" $1
54 }
55
56 fixRunPath $out/lib/libgpuarray.so
57 '';
58
59 propagatedBuildInputs = [
60 numpy
61 six
62 Mako
63 ];
64
65 enableParallelBuilding = true;
66
67 buildInputs = [
68 cmake
69 cython
70 nose
71 ];
72
73 meta = with stdenv.lib; {
74 homepage = "https://github.com/Theano/libgpuarray";
75 description = "Library to manipulate tensors on GPU.";
76 license = licenses.free;
77 maintainers = with maintainers; [ artuuge ];
78 platforms = platforms.linux;
79 };
80
81}