Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 90 lines 2.9 kB view raw
1{ 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 ( stdenv.lib.optional cudaSupport libgpuarray_ 44 ++ stdenv.lib.optional cudnnSupport cudnn ); 45 46 libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; }; 47 48in buildPythonPackage rec { 49 pname = "Theano"; 50 version = "1.0.4"; 51 52 disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3"); 53 54 src = fetchPypi { 55 inherit pname version; 56 sha256 = "35c9bbef56b61ffa299265a42a4e8f8cb5a07b2997dabaef0f8830b397086913"; 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 '' + stdenv.lib.optionalString cudaSupport '' 64 substituteInPlace theano/configdefaults.py \ 65 --replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')' 66 '' + stdenv.lib.optionalString cudnnSupport '' 67 substituteInPlace theano/configdefaults.py \ 68 --replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')' 69 ''; 70 71 preCheck = '' 72 mkdir -p check-phase 73 export HOME=$(pwd)/check-phase 74 ''; 75 doCheck = false; 76 # takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'" 77 # when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276, 78 # the fix for which hasn't been merged yet. 79 80 # keep Nose around since running the tests by hand is possible from Python or bash 81 checkInputs = [ nose ]; 82 propagatedBuildInputs = [ numpy numpy.blas scipy six libgpuarray_ ]; 83 84 meta = with stdenv.lib; { 85 homepage = http://deeplearning.net/software/theano/; 86 description = "A Python library for large-scale array computation"; 87 license = licenses.bsd3; 88 maintainers = with maintainers; [ maintainers.bcdarwin ]; 89 }; 90}