diff options
author | Frederik Rietdijk <freddyrietdijk@fridh.nl> | 2018-08-08 17:43:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 17:43:04 +0200 |
commit | 52e7817aa2c33b8569b6fdc884f98a34fbf6f61e (patch) | |
tree | 2fe8cd187e12153f03904a23cfbca0d70ca96a32 | |
parent | d6b3318b938b66005ee94f984469905a9fbb8cd8 (diff) | |
parent | 303a3f972eabd1eda0b3fbd4051d31d258402ad3 (diff) | |
download | nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar.gz nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar.bz2 nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar.lz nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar.xz nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.tar.zst nixlib-52e7817aa2c33b8569b6fdc884f98a34fbf6f61e.zip |
Merge pull request #26580 from twhitehead/theano-cleanup
Theano cleanup
-rw-r--r-- | pkgs/development/python-modules/Theano/default.nix | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/pkgs/development/python-modules/Theano/default.nix b/pkgs/development/python-modules/Theano/default.nix index e2b31cdda794..793488f0b136 100644 --- a/pkgs/development/python-modules/Theano/default.nix +++ b/pkgs/development/python-modules/Theano/default.nix @@ -1,8 +1,8 @@ { stdenv +, runCommandCC , lib , fetchPypi , gcc -, writeScriptBin , buildPythonPackage , isPyPy , pythonOlder @@ -24,19 +24,24 @@ assert cudaSupport -> nvidia_x11 != null && cudnn != null; let - extraFlags = - lib.optionals cudaSupport [ "-I ${cudatoolkit}/include" "-L ${cudatoolkit}/lib" ] - ++ lib.optionals cudnnSupport [ "-I ${cudnn}/include" "-L ${cudnn}/lib" ] - ++ lib.optionals cudaSupport [ "-I ${libgpuarray}/include" "-L ${libgpuarray}/lib" ]; + wrapped = command: buildTop: buildInputs: + runCommandCC "${command}-wrapped" { inherit buildInputs; } '' + type -P '${command}' || { echo '${command}: not found'; exit 1; } + cat > "$out" <<EOF + #!$(type -P bash) + $(declare -xp | sed -e '/^[^=]\+="\('"''${NIX_STORE//\//\\/}"'\|[^\/]\)/!d') + declare -x NIX_BUILD_TOP="${buildTop}" + $(type -P '${command}') "\$@" + EOF + chmod +x "$out" + ''; - gcc_ = writeScriptBin "g++" '' - #!${stdenv.shell} - export NIX_CC_WRAPPER_${stdenv.cc.infixSalt}_TARGET_HOST=1 - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${toString extraFlags}" - exec ${gcc}/bin/g++ "$@" - ''; + # Theano spews warnings and disabled flags if the compiler isn't named g++ + cxx_compiler = wrapped "g++" "\\$HOME/.theano" + ( stdenv.lib.optional cudaSupport libgpuarray_ + ++ stdenv.lib.optional cudnnSupport cudnn ); - libgpuarray_ = libgpuarray.override { inherit cudaSupport; }; + libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; }; in buildPythonPackage rec { pname = "Theano"; @@ -50,12 +55,15 @@ in buildPythonPackage rec { }; postPatch = '' - sed -i 's,g++,${gcc_}/bin/g++,g' theano/configdefaults.py - '' + lib.optionalString cudnnSupport '' - sed -i \ - -e "s,ctypes.util.find_library('cudnn'),'${cudnn}/lib/libcudnn.so',g" \ - -e "s/= _dnn_check_compile()/= (True, None)/g" \ - theano/gpuarray/dnn.py + substituteInPlace theano/configdefaults.py \ + --replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${cxx_compiler}'\''', is_valid=warn_cxx)' \ + --replace 'rc == 0 and config.cxx != ""' 'config.cxx != ""' + '' + stdenv.lib.optionalString cudaSupport '' + substituteInPlace theano/configdefaults.py \ + --replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')' + '' + stdenv.lib.optionalString cudnnSupport '' + substituteInPlace theano/configdefaults.py \ + --replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')' ''; preCheck = '' |