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