diff --git a/pkgs/development/python-modules/tensorflow/bin.nix b/pkgs/development/python-modules/tensorflow/bin.nix index 7b9cbf1f990..f5960f0e29e 100644 --- a/pkgs/development/python-modules/tensorflow/bin.nix +++ b/pkgs/development/python-modules/tensorflow/bin.nix @@ -30,6 +30,10 @@ , keras-applications , keras-preprocessing , addOpenGLRunpath +, astunparse +, flatbuffers +, h5py +, typing-extensions }: # We keep this binary build for two reasons: @@ -48,13 +52,14 @@ let variant = if cudaSupport then "-gpu" else ""; pname = "tensorflow${variant}"; - + metadataPatch = ./relax-dependencies-metadata.patch; + patch = ./relax-dependencies.patch; in buildPythonPackage { inherit pname; inherit (packages) version; format = "wheel"; - disabled = pythonAtLeast "3.8"; + disabled = pythonAtLeast "3.9"; src = let pyVerNoDot = lib.strings.stringAsChars (x: if x == "." then "" else x) python.pythonVersion; @@ -64,6 +69,9 @@ in buildPythonPackage { in fetchurl packages.${key}; propagatedBuildInputs = [ + astunparse + flatbuffers + typing-extensions protobuf numpy scipy @@ -80,6 +88,7 @@ in buildPythonPackage { tensorflow-tensorboard_2 keras-applications keras-preprocessing + h5py ] ++ lib.optional (!isPy3k) mock ++ lib.optionals (pythonOlder "3.4") [ backports_weakref ]; @@ -93,24 +102,15 @@ in buildPythonPackage { pushd dist - # Unpack the wheel file. wheel unpack --dest unpacked ./*.whl - - # Tensorflow wheels tightly constrain the versions of gast, tensorflow-estimator and scipy. - # This code relaxes these requirements: - substituteInPlace ./unpacked/tensorflow*/tensorflow_core/tools/pip_package/setup.py \ - --replace "tensorflow_estimator >= 2.1.0rc0, < 2.2.0" "tensorflow_estimator" \ - --replace "tensorboard >= 2.1.0, < 2.2.0" "tensorboard" \ - --replace "gast == 0.2.2" "gast" \ - --replace "scipy == 1.2.2" "scipy" - - substituteInPlace ./unpacked/tensorflow*/tensorflow*.dist-info/METADATA \ - --replace "gast (==0.2.2)" "gast" \ - --replace "tensorflow-estimator (<2.2.0,>=2.1.0rc0)" "tensorflow_estimator" \ - --replace "tensorboard (<2.2.0,>=2.1.0)" "tensorboard" \ - --replace "scipy (==1.4.1)" "scipy" - - # Pack the wheel file back up. + ( + cd unpacked/tensorflow* + # relax too strict versions in setup.py + patch -p 1 < ${patch} + cd *.dist-info + # relax too strict versions in *.dist-info/METADATA + patch -p 3 < ${metadataPatch} + ) wheel pack ./unpacked/tensorflow* popd @@ -143,14 +143,19 @@ in buildPythonPackage { # TODO: Create this list programmatically, and remove paths that aren't # actually needed. rrPathArr=( - "$out/${python.sitePackages}/tensorflow_core/" - "$out/${python.sitePackages}/tensorflow_core/compiler/tf2tensorrt/" - "$out/${python.sitePackages}/tensorflow_core/compiler/tf2xla/ops/" - "$out/${python.sitePackages}/tensorflow_core/lite/experimental/microfrontend/python/ops/" - "$out/${python.sitePackages}/tensorflow_core/lite/python/interpreter_wrapper/" - "$out/${python.sitePackages}/tensorflow_core/lite/python/optimize/" - "$out/${python.sitePackages}/tensorflow_core/python/" - "$out/${python.sitePackages}/tensorflow_core/python/framework/" + "$out/${python.sitePackages}/tensorflow/" + "$out/${python.sitePackages}/tensorflow/core/kernels" + "$out/${python.sitePackages}/tensorflow/compiler/tf2tensorrt/" + "$out/${python.sitePackages}/tensorflow/compiler/tf2xla/ops/" + "$out/${python.sitePackages}/tensorflow/lite/experimental/microfrontend/python/ops/" + "$out/${python.sitePackages}/tensorflow/lite/python/interpreter_wrapper/" + "$out/${python.sitePackages}/tensorflow/lite/python/optimize/" + "$out/${python.sitePackages}/tensorflow/python/" + "$out/${python.sitePackages}/tensorflow/python/framework/" + "$out/${python.sitePackages}/tensorflow/python/autograph/impl/testing" + "$out/${python.sitePackages}/tensorflow/python/data/experimental/service" + "$out/${python.sitePackages}/tensorflow/python/framework" + "$out/${python.sitePackages}/tensorflow/python/profiler/internal" "${rpath}" ) @@ -189,8 +194,5 @@ in buildPythonPackage { license = licenses.asl20; maintainers = with maintainers; [ jyp abbradar cdepillabout ]; platforms = [ "x86_64-linux" "x86_64-darwin" ]; - # Python 2.7 build uses different string encoding. - # See https://github.com/NixOS/nixpkgs/pull/37044#issuecomment-373452253 - broken = stdenv.isDarwin && !isPy3k; }; } diff --git a/pkgs/development/python-modules/tensorflow/binary-hashes.nix b/pkgs/development/python-modules/tensorflow/binary-hashes.nix index 90848e93273..4485e2b6145 100644 --- a/pkgs/development/python-modules/tensorflow/binary-hashes.nix +++ b/pkgs/development/python-modules/tensorflow/binary-hashes.nix @@ -1,51 +1,39 @@ { -version = "2.1.0"; -linux_py_27_gpu = { - url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl"; - sha256 = "17lnhr7vdrls68c79n3sah5rpd0q1x2v5m84azvlyxxh2wpypfmb"; -}; -linux_py_27_cpu = { - url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl"; - sha256 = "10lz3i4pcpgqrcbjmxm0n7k1gsqlpna3kdid902j2fy060cpi93z"; -}; -linux_py_35_gpu = { - url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl"; - sha256 = "09s081n08dpmflwgir3zwzfijfpmahbh2gy5fn5bv5ll86g1szsy"; -}; -linux_py_35_cpu = { - url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl"; - sha256 = "1aa7v9fnvx03hqvhl3x3xcn41qy6qxw5xybg54ifjvvicp455c8l"; -}; -linux_py_36_gpu = { - url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl"; - sha256 = "1dqp080ljbl9v3115vjp63ls0fimiwym6zxyanyhrlk8kwsq20zc"; -}; +version = "2.4.0"; linux_py_36_cpu = { - url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl"; - sha256 = "133z8anx7xm9rr5i9s9dwnp1wf06nr6s7q1lbs4lxpk6kn9nl480"; -}; -linux_py_37_gpu = { - url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl"; - sha256 = "0yabl3xmcpr67w0zksqs3qc68nl9ax0vcd7w7b35nq8f65xl0ghy"; + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp36-cp36m-manylinux2010_x86_64.whl"; + sha256 = "0pn0cjf50q0xsv6k0vihrz22kr392anznvdhxv80gk52c6lcgmsc"; }; linux_py_37_cpu = { - url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl"; - sha256 = "04gngbngyg7p1gwx1q89my0cl8j7lq4kknqh51s2ynrix71zvsy6"; + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp37-cp37m-manylinux2010_x86_64.whl"; + sha256 = "0mdd83c0invqfy58qmpa3hk4yml5ic7wlwggyd5wpikadlv8vq89"; }; -mac_py_27_cpu = { - url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp27-cp27m-macosx_10_9_x86_64.whl"; - sha256 = "1mprp72w5kk0lyjm2mh4lf57827xk3wsg28c4gizwm00ydfgacg6"; +linux_py_38_cpu = { + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp38-cp38-manylinux2010_x86_64.whl"; + sha256 = "1mm1yz9aj3v6fxfpxh7wy37rvsncr0b5y6glqlcxmhr6mqfp8k6d"; }; -mac_py_35_cpu = { - url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp35-cp35m-macosx_10_6_intel.whl"; - sha256 = "1as7brf5ai6r7v1di9646jfrbnirpk2b0d1g29mn3shavb62kw8w"; +linux_py_36_gpu = { + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp36-cp36m-manylinux2010_x86_64.whl"; + sha256 = "113iygiq2kmj97g0glhcqng6rhl3rrj1iqw5xj1d5hla8xjy8cfv"; +}; +linux_py_37_gpu = { + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp37-cp37m-manylinux2010_x86_64.whl"; + sha256 = "19ap8xx2j5nbmnqv5rzf1ryfvw2fbs6bm0fxjqrvhc3jxys6yqqs"; +}; +linux_py_38_gpu = { + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp38-cp38-manylinux2010_x86_64.whl"; + sha256 = "0ly3cinzj6j3b547sw8bd3p774khn3b14cgrj7nvfrz668d3f89x"; }; mac_py_36_cpu = { - url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp36-cp36m-macosx_10_9_x86_64.whl"; - sha256 = "1v1rw9kjrskhcq1yas4ly2yfnzf2i1pjh6qg6zixfbkpkw7sw3wc"; + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp36-cp36m-macosx_10_14_x86_64.whl"; + sha256 = "1b5ld1wj48l1i5s3vk8db5m578zdg4xfl0m1lc8w5lx1vi4cwsjp"; }; mac_py_37_cpu = { - url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl"; - sha256 = "1hh4n0d97mrq35cmmsrnlmcv9vlswsyjy368lj3pda3y9dvck3rf"; + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp37-cp37m-macosx_10_14_x86_64.whl"; + sha256 = "1mgfyjgcwvx5jzawrpfnbch5sqw7kpnzp35rfxj22kwdsl28r47r"; +}; +mac_py_38_cpu = { + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp38-cp38-macosx_10_14_x86_64.whl"; + sha256 = "034qh0nk786wxzma58179g086x479c3pd9vi8v8p26grs6f2fm0p"; }; } diff --git a/pkgs/development/python-modules/tensorflow/prefetcher.sh b/pkgs/development/python-modules/tensorflow/prefetcher.sh index abb0faac283..8b22affa17a 100755 --- a/pkgs/development/python-modules/tensorflow/prefetcher.sh +++ b/pkgs/development/python-modules/tensorflow/prefetcher.sh @@ -1,23 +1,22 @@ #!/usr/bin/env bash -version=2.1.0 +version="2.4.0" + +bucket="https://storage.googleapis.com/tensorflow" # List of binary wheels for Tensorflow. The most recent versions can be found # on the following page: # https://www.tensorflow.org/install/pip?lang=python3#package-location url_and_key_list=( - "linux_py_27_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp27-cp27mu-manylinux2010_x86_64.whl" - "linux_py_27_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp27-cp27mu-manylinux2010_x86_64.whl" - "linux_py_35_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp35-cp35m-manylinux2010_x86_64.whl" - "linux_py_35_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp35-cp35m-manylinux2010_x86_64.whl" - "linux_py_36_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" - "linux_py_36_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" - "linux_py_37_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" - "linux_py_37_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" - "mac_py_27_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp27-cp27m-macosx_10_9_x86_64.whl" - "mac_py_35_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp35-cp35m-macosx_10_6_intel.whl" - "mac_py_36_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp36-cp36m-macosx_10_9_x86_64.whl" - "mac_py_37_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp37-cp37m-macosx_10_9_x86_64.whl" +"linux_py_36_cpu $bucket/linux/cpu/tensorflow_cpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" +"linux_py_37_cpu $bucket/linux/cpu/tensorflow_cpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" +"linux_py_38_cpu $bucket/linux/cpu/tensorflow_cpu-${version}-cp38-cp38-manylinux2010_x86_64.whl" +"linux_py_36_gpu $bucket/linux/gpu/tensorflow_gpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" +"linux_py_37_gpu $bucket/linux/gpu/tensorflow_gpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" +"linux_py_38_gpu $bucket/linux/gpu/tensorflow_gpu-${version}-cp38-cp38-manylinux2010_x86_64.whl" +"mac_py_36_cpu $bucket/mac/cpu/tensorflow-${version}-cp36-cp36m-macosx_10_14_x86_64.whl" +"mac_py_37_cpu $bucket/mac/cpu/tensorflow-${version}-cp37-cp37m-macosx_10_14_x86_64.whl" +"mac_py_38_cpu $bucket/mac/cpu/tensorflow-${version}-cp38-cp38-macosx_10_14_x86_64.whl" ) hashfile=binary-hashes.nix diff --git a/pkgs/development/python-modules/tensorflow/relax-dependencies-metadata.patch b/pkgs/development/python-modules/tensorflow/relax-dependencies-metadata.patch new file mode 100644 index 00000000000..1be4fd5bc7d --- /dev/null +++ b/pkgs/development/python-modules/tensorflow/relax-dependencies-metadata.patch @@ -0,0 +1,46 @@ +diff -ur unpacked/tensorflow-2.4.0/tensorflow-2.4.0.dist-info/METADATA unpacked.new/tensorflow-2.4.0/tensorflow-2.4.0.dist-info/METADATA +--- unpacked/tensorflow-2.4.0/tensorflow-2.4.0.dist-info/METADATA 2021-05-06 23:51:40.298995191 -0700 ++++ unpacked.new/tensorflow-2.4.0/tensorflow-2.4.0.dist-info/METADATA 2021-05-07 00:03:49.856882153 -0700 +@@ -27,24 +27,24 @@ + Classifier: Topic :: Software Development :: Libraries + Classifier: Topic :: Software Development :: Libraries :: Python Modules + Description-Content-Type: text/markdown +-Requires-Dist: absl-py (~=0.10) +-Requires-Dist: astunparse (~=1.6.3) +-Requires-Dist: flatbuffers (~=1.12.0) +-Requires-Dist: google-pasta (~=0.2) +-Requires-Dist: h5py (~=2.10.0) +-Requires-Dist: keras-preprocessing (~=1.1.2) +-Requires-Dist: numpy (~=1.19.2) +-Requires-Dist: opt-einsum (~=3.3.0) +-Requires-Dist: protobuf (>=3.9.2) +-Requires-Dist: six (~=1.15.0) +-Requires-Dist: termcolor (~=1.1.0) +-Requires-Dist: typing-extensions (~=3.7.4) +-Requires-Dist: wheel (~=0.35) +-Requires-Dist: wrapt (~=1.12.1) +-Requires-Dist: gast (==0.3.3) +-Requires-Dist: tensorboard (~=2.4) +-Requires-Dist: tensorflow-estimator (<2.5.0,>=2.4.0rc0) +-Requires-Dist: grpcio (~=1.32.0) ++Requires-Dist: absl-py ++Requires-Dist: astunparse ++Requires-Dist: flatbuffers ++Requires-Dist: google-pasta ++Requires-Dist: h5py ++Requires-Dist: keras-preprocessing ++Requires-Dist: numpy ++Requires-Dist: opt-einsum ++Requires-Dist: protobuf ++Requires-Dist: six ++Requires-Dist: termcolor ++Requires-Dist: typing-extensions ++Requires-Dist: wheel ++Requires-Dist: wrapt ++Requires-Dist: gast ++Requires-Dist: tensorboard ++Requires-Dist: tensorflow-estimator ++Requires-Dist: grpcio + + [![Python](https://img.shields.io/pypi/pyversions/tensorflow.svg?style=plastic)](https://badge.fury.io/py/tensorflow) + [![PyPI](https://badge.fury.io/py/tensorflow.svg)](https://badge.fury.io/py/tensorflow) \ No newline at end of file