1{ stdenv 2, buildPythonPackage 3, fetchFromGitHub 4, cmake 5, cython 6, numpy 7, Mako 8, six 9, nose 10, beaker 11, memcached 12, pkgconfig 13, glibc 14, clblas 15, Babel 16, pygments 17, scipy 18, python 19, cudatoolkit 20, nvidia_x11 21}: 22buildPythonPackage rec { 23 name = "libgpuarray-cuda-${version}"; 24 version = "-9998.0"; 25 26 src = fetchFromGitHub { 27 owner = "Theano"; 28 repo = "libgpuarray"; 29 rev = "fc36a40526c0a8303ace6c574ffdefba7feafe17"; 30 sha256 = "1kb0k42addqjxiahlcbv6v6271yhsmz71j12186fpy60870i7zm7"; 31 }; 32 33 doCheck = true; 34 35 configurePhase = '' 36 mkdir -p Build/Install 37 pushd Build 38 39 cmake .. -DCMAKE_BUILD_TYPE=Release \ 40 -DCMAKE_INSTALL_PREFIX=./Install \ 41 -DCLBLAS_ROOT_DIR=${clblas} 42 43 popd 44 ''; 45 46 preBuild = '' 47 pushd Build 48 make 49 make install 50 51 function fixRunPath { 52 p=$(patchelf --print-rpath $1) 53 patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ cudatoolkit clblas nvidia_x11 ]}" $1 54 } 55 56 fixRunPath Install/lib/libgpuarray.so 57 58 popd 59 ''; 60 61 setupPyBuildFlags = [ "-L $(pwd)/Build/Install/lib" "-I $(pwd)/Build/Install/include" ]; 62 63 preInstall = '' 64 cp -r Build/Install $out 65 ''; 66 67 postInstall = '' 68 pushd $out/${python.sitePackages}/pygpu 69 for f in $(find $out/pygpu -name "*.h"); do 70 ln -s $f $(basename $f) 71 done 72 popd 73 ''; 74 checkPhase = '' 75 mkdir -p my_bin 76 pushd my_bin 77 78 cat > libgpuarray_run_tests << EOF 79#!/bin/sh 80if [ \$# -eq 0 ]; then 81 echo "No argument provided." 82 echo "Available tests:" 83 ls $out/${python.sitePackages}/pygpu/tests | grep "test_" 84 exit 1 85else 86 nosetests -v "$out/${python.sitePackages}/pygpu/tests/\$@" 87fi 88EOF 89 90 chmod +x libgpuarray_run_tests 91 popd 92 93 cp -r my_bin $out/bin 94 ''; 95 96 dontStrip = true; 97 98 propagatedBuildInputs = [ 99 numpy 100 scipy 101 nose 102 six 103 Mako 104 ]; 105 106 buildInputs = [ 107 cmake 108 cython 109 beaker 110 memcached 111 pkgconfig 112 glibc 113 Babel 114 pygments 115 numpy.blas 116 cudatoolkit 117 nvidia_x11 118 clblas 119 ]; 120 121 meta = with stdenv.lib; { 122 homepage = https://github.com/Theano/libgpuarray; 123 description = "Library to manipulate tensors on GPU."; 124 license = licenses.free; 125 maintainers = with maintainers; [ artuuge ]; 126 platforms = platforms.linux; 127 }; 128 129}