···
···
28
-
lib.optionals cudaSupport [ "-I ${cudatoolkit}/include" "-L ${cudatoolkit}/lib" ]
29
-
++ lib.optionals cudnnSupport [ "-I ${cudnn}/include" "-L ${cudnn}/lib" ]
30
-
++ lib.optionals cudaSupport [ "-I ${libgpuarray}/include" "-L ${libgpuarray}/lib" ];
27
+
wrapped = command: buildTop: buildInputs:
28
+
runCommandCC "${command}-wrapped" { inherit buildInputs; } ''
29
+
type -P '${command}' || { echo '${command}: not found'; exit 1; }
32
+
$(declare -xp | sed -e '/^[^=]\+="\('"''${NIX_STORE//\//\\/}"'\|[^\/]\)/!d')
33
+
declare -x NIX_BUILD_TOP="${buildTop}"
34
+
$(type -P '${command}') "\$@"
32
-
gcc_ = writeScriptBin "g++" ''
34
-
export NIX_CC_WRAPPER_${stdenv.cc.infixSalt}_TARGET_HOST=1
35
-
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${toString extraFlags}"
36
-
exec ${gcc}/bin/g++ "$@"
39
+
# Theano spews warnings and disabled flags if the compiler isn't named g++
40
+
cxx_compiler = wrapped "g++" "\\$HOME/.theano"
41
+
( stdenv.lib.optional cudaSupport libgpuarray_
42
+
++ stdenv.lib.optional cudnnSupport cudnn );
39
-
libgpuarray_ = libgpuarray.override { inherit cudaSupport; };
44
+
libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; };
in buildPythonPackage rec {
···
53
-
sed -i 's,g++,${gcc_}/bin/g++,g' theano/configdefaults.py
54
-
'' + lib.optionalString cudnnSupport ''
56
-
-e "s,ctypes.util.find_library('cudnn'),'${cudnn}/lib/libcudnn.so',g" \
57
-
-e "s/= _dnn_check_compile()/= (True, None)/g" \
58
-
theano/gpuarray/dnn.py
58
+
substituteInPlace theano/configdefaults.py \
59
+
--replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${cxx_compiler}'\''', is_valid=warn_cxx)' \
60
+
--replace 'rc == 0 and config.cxx != ""' 'config.cxx != ""'
61
+
'' + stdenv.lib.optionalString cudaSupport ''
62
+
substituteInPlace theano/configdefaults.py \
63
+
--replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')'
64
+
'' + stdenv.lib.optionalString cudnnSupport ''
65
+
substituteInPlace theano/configdefaults.py \
66
+
--replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')'