at 22.05-pre 3.0 kB view raw
1{ lib, stdenv 2, runCommandCC 3, fetchPypi 4, buildPythonPackage 5, isPyPy 6, pythonOlder 7, isPy3k 8, nose 9, numpy 10, scipy 11, setuptools 12, six 13, libgpuarray 14, cudaSupport ? false, cudatoolkit 15, cudnnSupport ? false, cudnn 16}: 17 18assert cudnnSupport -> cudaSupport; 19 20let 21 wrapped = command: buildTop: buildInputs: 22 runCommandCC "${command}-wrapped" { inherit buildInputs; } '' 23 type -P '${command}' || { echo '${command}: not found'; exit 1; } 24 cat > "$out" <<EOF 25 #!$(type -P bash) 26 $(declare -xp | sed -e '/^[^=]\+="\('"''${NIX_STORE//\//\\/}"'\|[^\/]\)/!d') 27 declare -x NIX_BUILD_TOP="${buildTop}" 28 $(type -P '${command}') "\$@" 29 EOF 30 chmod +x "$out" 31 ''; 32 33 # Theano spews warnings and disabled flags if the compiler isn't named g++ 34 cxx_compiler_name = 35 if stdenv.cc.isGNU then "g++" else 36 if stdenv.cc.isClang then "clang++" else 37 throw "Unknown C++ compiler"; 38 cxx_compiler = wrapped cxx_compiler_name "\\$HOME/.theano" 39 ( lib.optional cudaSupport libgpuarray_ 40 ++ lib.optional cudnnSupport cudnn ); 41 42 libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; }; 43 44in buildPythonPackage rec { 45 pname = "Theano"; 46 version = "1.0.5"; 47 48 disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3"); 49 50 src = fetchPypi { 51 inherit pname version; 52 sha256 = "129f43ww2a6badfdr6b88kzjzz2b0wk0dwkvwb55z6dsagfkk53f"; 53 }; 54 55 postPatch = '' 56 substituteInPlace theano/configdefaults.py \ 57 --replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${cxx_compiler}'\''', is_valid=warn_cxx)' \ 58 --replace 'rc == 0 and config.cxx != ""' 'config.cxx != ""' 59 '' + lib.optionalString cudaSupport '' 60 substituteInPlace theano/configdefaults.py \ 61 --replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')' 62 '' + lib.optionalString cudnnSupport '' 63 substituteInPlace theano/configdefaults.py \ 64 --replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')' 65 ''; 66 67 # needs to be postFixup so it runs before pythonImportsCheck even when 68 # doCheck = false (meaning preCheck would be disabled) 69 postFixup = '' 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 # setuptools needed for cuda support 81 propagatedBuildInputs = [ 82 libgpuarray_ 83 numpy 84 numpy.blas 85 scipy 86 setuptools 87 six 88 ]; 89 90 pythonImportsCheck = [ "theano" ]; 91 92 meta = with lib; { 93 homepage = "https://github.com/Theano/Theano"; 94 description = "A Python library for large-scale array computation"; 95 license = licenses.bsd3; 96 maintainers = with maintainers; [ maintainers.bcdarwin ]; 97 }; 98}