tensorflow: fix python2 build

Avoid using PYTHONPATH, switch to python envs instead.

+24 -32
+24 -32
pkgs/development/python-modules/tensorflow/default.nix
··· 58 variant = if cudaSupport then "-gpu" else ""; 59 pname = "tensorflow${variant}"; 60 61 - # TODO: remove after there's support for setupPyDistFlags 62 - setuppy = ../../../development/interpreters/python/run_setup.py; 63 64 bazel-build = buildBazelPackage rec { 65 name = "${pname}-${version}"; ··· 96 # https://gitweb.gentoo.org/repo/gentoo.git/tree/sci-libs/tensorflow 97 98 nativeBuildInputs = [ 99 - swig which cython 100 ]; 101 102 buildInputs = [ 103 - python 104 jemalloc 105 openmpi 106 glibcLocales 107 git 108 109 - # python deps needed during wheel build time 110 - numpy 111 - keras-preprocessing 112 - protobuf 113 - wrapt 114 - gast 115 - astor 116 - absl-py 117 - termcolor 118 - keras-applications 119 - 120 # libs taken from system through the TF_SYS_LIBS mechanism 121 # grpc 122 sqlite ··· 133 giflib 134 re2 135 pkgs.lmdb 136 - 137 - # for building the wheel 138 - setuptools 139 - wheel 140 - ] ++ lib.optionals (!isPy3k) [ 141 - future 142 - mock 143 ] ++ lib.optionals cudaSupport [ 144 cudatoolkit 145 cudnn 146 nvidia_x11 147 ]; 148 - 149 150 # arbitrarily set to the current latest bazel version, overly careful 151 TF_IGNORE_MAX_BAZEL_VERSION = true; ··· 194 195 INCLUDEDIR = "${includes_joined}/include"; 196 197 - PYTHON_BIN_PATH = python.interpreter; 198 - 199 TF_NEED_GCP = true; 200 TF_NEED_HDFS = true; 201 TF_ENABLE_XLA = tfFeature xlaSupport; ··· 237 export PYTHON_LIB_PATH="$NIX_BUILD_TOP/site-packages" 238 export CC_OPT_FLAGS="${lib.concatStringsSep " " opt_flags}" 239 mkdir -p "$PYTHON_LIB_PATH" 240 ''; 241 242 configurePhase = '' ··· 313 rm $out/bin/tensorboard 314 ''; 315 316 - # TODO: remove after there's support for setupPyDistFlags 317 - buildPhase = '' 318 - runHook preBuild 319 - cp ${setuppy} nix_run_setup 320 - ${python.interpreter} nix_run_setup --project_name ${pname} bdist_wheel 321 - runHook postBuild 322 - ''; 323 324 # tensorflow/tools/pip_package/setup.py 325 propagatedBuildInputs = [
··· 58 variant = if cudaSupport then "-gpu" else ""; 59 pname = "tensorflow${variant}"; 60 61 + pythonEnv = python.withPackages (_: 62 + [ # python deps needed during wheel build time 63 + numpy 64 + keras-preprocessing 65 + protobuf 66 + wrapt 67 + gast 68 + astor 69 + absl-py 70 + termcolor 71 + keras-applications 72 + setuptools 73 + wheel 74 + ] ++ lib.optionals (!isPy3k) 75 + [ future 76 + mock 77 + ]); 78 79 bazel-build = buildBazelPackage rec { 80 name = "${pname}-${version}"; ··· 111 # https://gitweb.gentoo.org/repo/gentoo.git/tree/sci-libs/tensorflow 112 113 nativeBuildInputs = [ 114 + swig which pythonEnv 115 ]; 116 117 buildInputs = [ 118 jemalloc 119 openmpi 120 glibcLocales 121 git 122 123 # libs taken from system through the TF_SYS_LIBS mechanism 124 # grpc 125 sqlite ··· 136 giflib 137 re2 138 pkgs.lmdb 139 ] ++ lib.optionals cudaSupport [ 140 cudatoolkit 141 cudnn 142 nvidia_x11 143 ]; 144 145 # arbitrarily set to the current latest bazel version, overly careful 146 TF_IGNORE_MAX_BAZEL_VERSION = true; ··· 189 190 INCLUDEDIR = "${includes_joined}/include"; 191 192 + PYTHON_BIN_PATH = pythonEnv.interpreter; 193 + 194 TF_NEED_GCP = true; 195 TF_NEED_HDFS = true; 196 TF_ENABLE_XLA = tfFeature xlaSupport; ··· 232 export PYTHON_LIB_PATH="$NIX_BUILD_TOP/site-packages" 233 export CC_OPT_FLAGS="${lib.concatStringsSep " " opt_flags}" 234 mkdir -p "$PYTHON_LIB_PATH" 235 + 236 + # To avoid mixing Python 2 and Python 3 237 + unset PYTHONPATH 238 ''; 239 240 configurePhase = '' ··· 311 rm $out/bin/tensorboard 312 ''; 313 314 + setupPyGlobalFlags = [ "--project_name ${pname}" ]; 315 316 # tensorflow/tools/pip_package/setup.py 317 propagatedBuildInputs = [