From b314d01ad1c7138f3c499608cacb8b443059dec9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 22 Mar 2025 01:51:01 +0100 Subject: [PATCH 1/3] python312Packages.tensorflow: re-order inputs --- .../python-modules/tensorflow/bin.nix | 100 ++++++++++-------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/pkgs/development/python-modules/tensorflow/bin.nix b/pkgs/development/python-modules/tensorflow/bin.nix index 79495d4e9ac2..619c4222fb5d 100644 --- a/pkgs/development/python-modules/tensorflow/bin.nix +++ b/pkgs/development/python-modules/tensorflow/bin.nix @@ -1,40 +1,47 @@ { - stdenv, lib, - fetchurl, + stdenv, buildPythonPackage, - isPy3k, - astor, - gast, - google-pasta, - wrapt, - numpy, - six, - termcolor, - packaging, - protobuf, - absl-py, - grpcio, - mock, - scipy, + fetchurl, + + # buildInputs + llvmPackages, + + # build-system distutils, wheel, + + # dependencies jax, ml-dtypes, + absl-py, + astor, + astunparse, + flatbuffers, + gast, + google-pasta, + grpcio, + h5py, + numpy, opt-einsum, - tensorflow-estimator-bin, + packaging, + protobuf, + scipy, + six, tensorboard, + tensorflow-estimator-bin, + termcolor, + typing-extensions, + wrapt, + isPy3k, + mock, + config, cudaSupport ? config.cudaSupport, cudaPackages, zlib, python, addDriverRunpath, - astunparse, - flatbuffers, - h5py, - llvmPackages, - typing-extensions, }: # We keep this binary build for three reasons: @@ -68,38 +75,39 @@ buildPythonPackage rec { buildInputs = [ llvmPackages.openmp ]; - dependencies = [ - astunparse - flatbuffers - typing-extensions + build-system = [ distutils + wheel + ]; + + nativeBuildInputs = + lib.optionals cudaSupport [ addDriverRunpath ] + ++ lib.optionals isCudaJetson [ cudaPackages.autoAddCudaCompatRunpath ]; + + dependencies = [ + (if isCudaX64 then jax else ml-dtypes) + absl-py + astor + astunparse + distutils + flatbuffers + gast + google-pasta + grpcio + h5py + numpy + opt-einsum packaging protobuf - numpy scipy - (if isCudaX64 then jax else ml-dtypes) - termcolor - grpcio six - astor - absl-py - gast - opt-einsum - google-pasta - wrapt - tensorflow-estimator-bin tensorboard - h5py + tensorflow-estimator-bin + termcolor + typing-extensions + wrapt ] ++ lib.optional (!isPy3k) mock; - build-system = - [ - distutils - wheel - ] - ++ lib.optionals cudaSupport [ addDriverRunpath ] - ++ lib.optionals isCudaJetson [ cudaPackages.autoAddCudaCompatRunpath ]; - preConfigure = '' unset SOURCE_DATE_EPOCH From 69ee6f700c6d5a0d90e1af705cb7eaddda92f6bd Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 22 Mar 2025 01:55:25 +0100 Subject: [PATCH 2/3] python312Packages.tensorflow: cleanup dependencies --- .../python-modules/tensorflow/bin.nix | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pkgs/development/python-modules/tensorflow/bin.nix b/pkgs/development/python-modules/tensorflow/bin.nix index 619c4222fb5d..f6cbe2090694 100644 --- a/pkgs/development/python-modules/tensorflow/bin.nix +++ b/pkgs/development/python-modules/tensorflow/bin.nix @@ -9,27 +9,24 @@ # build-system distutils, - wheel, # dependencies - jax, ml-dtypes, absl-py, - astor, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, + libclang, numpy, opt-einsum, packaging, protobuf, - scipy, + requests, six, tensorboard, - tensorflow-estimator-bin, termcolor, typing-extensions, wrapt, @@ -57,7 +54,6 @@ let inherit (cudaPackages) cudatoolkit cudnn; isCudaJetson = cudaSupport && cudaPackages.cudaFlags.isJetsonBuild; - isCudaX64 = cudaSupport && stdenv.hostPlatform.isx86_64; in buildPythonPackage rec { pname = "tensorflow" + lib.optionalString cudaSupport "-gpu"; @@ -77,7 +73,6 @@ buildPythonPackage rec { build-system = [ distutils - wheel ]; nativeBuildInputs = @@ -85,24 +80,22 @@ buildPythonPackage rec { ++ lib.optionals isCudaJetson [ cudaPackages.autoAddCudaCompatRunpath ]; dependencies = [ - (if isCudaX64 then jax else ml-dtypes) absl-py - astor astunparse - distutils flatbuffers gast google-pasta grpcio h5py + libclang + ml-dtypes numpy opt-einsum packaging protobuf - scipy + requests six tensorboard - tensorflow-estimator-bin termcolor typing-extensions wrapt From 91c40e3a44a2bd018453615ec3ec85626769e715 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 22 Mar 2025 02:17:49 +0100 Subject: [PATCH 3/3] python312Packages.tensorflow: remove unnecessary dependency patching --- .../python-modules/tensorflow/bin.nix | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/pkgs/development/python-modules/tensorflow/bin.nix b/pkgs/development/python-modules/tensorflow/bin.nix index f6cbe2090694..f8476a2f1821 100644 --- a/pkgs/development/python-modules/tensorflow/bin.nix +++ b/pkgs/development/python-modules/tensorflow/bin.nix @@ -114,28 +114,6 @@ buildPythonPackage rec { mv "$f" "$(sed -E 's/(nv[0-9]+)\.0*([0-9]+)/\1.\2/' <<< "$f")" done - wheel unpack --dest unpacked ./*.whl - rm ./*.whl - ( - cd unpacked/tensorflow* - # Adjust dependency requirements: - # - Relax flatbuffers, gast, protobuf, tensorboard, and tensorflow-estimator version requirements that don't match what we have packaged - # - The purpose of python3Packages.libclang is not clear at the moment and we don't have it packaged yet - # - keras and tensorlow-io-gcs-filesystem will be considered as optional for now. - # - numpy was pinned to fix some internal tests: https://github.com/tensorflow/tensorflow/issues/60216 - sed -i *.dist-info/METADATA \ - -e "/Requires-Dist: flatbuffers/d" \ - -e "/Requires-Dist: gast/d" \ - -e "/Requires-Dist: keras/d" \ - -e "/Requires-Dist: libclang/d" \ - -e "/Requires-Dist: protobuf/d" \ - -e "/Requires-Dist: tensorboard/d" \ - -e "/Requires-Dist: tensorflow-estimator/d" \ - -e "/Requires-Dist: tensorflow-io-gcs-filesystem/d" \ - -e "s/Requires-Dist: numpy (.*)/Requires-Dist: numpy/" - ) - wheel pack ./unpacked/tensorflow* - popd '';