at 18.09-beta 2.8 kB view raw
1{ stdenv 2, runCommandCC 3, lib 4, fetchPypi 5, gcc 6, buildPythonPackage 7, isPyPy 8, pythonOlder 9, isPy3k 10, nose 11, numpy 12, scipy 13, six 14, libgpuarray 15, cudaSupport ? false, cudatoolkit 16, cudnnSupport ? false, cudnn 17, nvidia_x11 18}: 19 20assert cudnnSupport -> cudaSupport; 21 22assert cudaSupport -> nvidia_x11 != null 23 && cudatoolkit != null 24 && cudnn != null; 25 26let 27 wrapped = command: buildTop: buildInputs: 28 runCommandCC "${command}-wrapped" { inherit buildInputs; } '' 29 type -P '${command}' || { echo '${command}: not found'; exit 1; } 30 cat > "$out" <<EOF 31 #!$(type -P bash) 32 $(declare -xp | sed -e '/^[^=]\+="\('"''${NIX_STORE//\//\\/}"'\|[^\/]\)/!d') 33 declare -x NIX_BUILD_TOP="${buildTop}" 34 $(type -P '${command}') "\$@" 35 EOF 36 chmod +x "$out" 37 ''; 38 39 # Theano spews warnings and disabled flags if the compiler isn't named g++ 40 cxx_compiler = wrapped "g++" "\\$HOME/.theano" 41 ( stdenv.lib.optional cudaSupport libgpuarray_ 42 ++ stdenv.lib.optional cudnnSupport cudnn ); 43 44 libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; }; 45 46in buildPythonPackage rec { 47 pname = "Theano"; 48 version = "1.0.2"; 49 50 disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3"); 51 52 src = fetchPypi { 53 inherit pname version; 54 sha256 = "6768e003d328a17011e6fca9126fbb8a6ffd3bb13cb21c450f3e724cca29abde"; 55 }; 56 57 postPatch = '' 58 substituteInPlace theano/configdefaults.py \ 59 --replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${cxx_compiler}'\''', is_valid=warn_cxx)' \ 60 --replace 'rc == 0 and config.cxx != ""' 'config.cxx != ""' 61 '' + stdenv.lib.optionalString cudaSupport '' 62 substituteInPlace theano/configdefaults.py \ 63 --replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')' 64 '' + stdenv.lib.optionalString cudnnSupport '' 65 substituteInPlace theano/configdefaults.py \ 66 --replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')' 67 ''; 68 69 preCheck = '' 70 mkdir -p check-phase 71 export HOME=$(pwd)/check-phase 72 ''; 73 doCheck = false; 74 # takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'" 75 # when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276, 76 # the fix for which hasn't been merged yet. 77 78 # keep Nose around since running the tests by hand is possible from Python or bash 79 checkInputs = [ nose ]; 80 propagatedBuildInputs = [ numpy numpy.blas scipy six libgpuarray_ ]; 81 82 meta = with stdenv.lib; { 83 homepage = http://deeplearning.net/software/theano/; 84 description = "A Python library for large-scale array computation"; 85 license = licenses.bsd3; 86 maintainers = with maintainers; [ maintainers.bcdarwin ]; 87 }; 88}