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