Theano: get theano to use a captured build environment
This commit is contained in:
parent
8413a541d5
commit
303a3f972e
@ -1,8 +1,8 @@
|
||||
{ stdenv
|
||||
, runCommandCC
|
||||
, lib
|
||||
, fetchPypi
|
||||
, gcc
|
||||
, writeScriptBin
|
||||
, buildPythonPackage
|
||||
, isPyPy
|
||||
, pythonOlder
|
||||
@ -24,17 +24,22 @@ 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 cudatoolkit; };
|
||||
|
||||
@ -51,7 +56,7 @@ in buildPythonPackage rec {
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace theano/configdefaults.py \
|
||||
--replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${gcc_}/bin/g++'\''', is_valid=warn_cxx)' \
|
||||
--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 \
|
||||
|
Loading…
Reference in New Issue
Block a user