tensorflow: fix python2 build

Avoid using PYTHONPATH, switch to python envs instead.

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