1{ lib 2, fetchFromGitHub 3, bazel_0_26 4, buildBazelPackage 5, buildPythonPackage 6, git 7, python 8, six 9, absl-py 10, semantic-version 11, contextlib2 12, wrapt 13, tensorflow 14, tensorflow-probability 15, tensorflow-estimator 16}: 17 18let 19 version = "1.33"; 20 21 # first build all binaries and generate setup.py using bazel 22 bazel-build = buildBazelPackage { 23 bazel = bazel_0_26; 24 25 name = "dm-sonnet-bazel-${version}"; 26 27 src = fetchFromGitHub { 28 owner = "deepmind"; 29 repo = "sonnet"; 30 rev = "v${version}"; 31 sha256 = "1nqsja1s8jrkq6v1whgh7smk17313mjr9vs3k5c1m8px4yblzhqc"; 32 }; 33 34 nativeBuildInputs = [ 35 git # needed to fetch the bazel deps (protobuf in particular) 36 ]; 37 38 # see https://github.com/deepmind/sonnet/blob/master/docs/INSTALL.md 39 bazelTarget = ":install"; 40 41 fetchAttrs = { 42 sha256 = "09dzxs2v5wpiaxrz7qj257q1fbx0gxwbk0jyx58n81m5kys7yj9k"; 43 }; 44 45 buildAttrs = { 46 preBuild = '' 47 patchShebangs . 48 ''; 49 50 installPhase = '' 51 # do not generate a wheel, instead just copy the generated files to $out to be installed by buildPythonPackage 52 sed -i 's,.*bdist_wheel.*,cp -rL . "$out"; exit 0,' bazel-bin/install 53 54 # the target directory "dist" does not actually matter since we're not generating a wheel 55 bazel-bin/install dist 56 ''; 57 }; 58 }; 59 60# now use pip to install the package prepared by bazel 61in buildPythonPackage { 62 pname = "dm-sonnet"; 63 inherit version; 64 65 src = bazel-build; 66 67 propagatedBuildInputs = [ 68 six 69 absl-py 70 semantic-version 71 contextlib2 72 wrapt 73 tensorflow 74 tensorflow-probability 75 tensorflow-estimator 76 ]; 77 78 # not sure how to properly run the real test suite -- through bazel? 79 checkPhase = '' 80 ${python.interpreter} -c "import sonnet" 81 ''; 82 83 meta = with lib; { 84 description = "TensorFlow-based neural network library"; 85 homepage = "https://sonnet.dev"; 86 license = licenses.asl20; 87 maintainers = with maintainers; [ timokau ]; 88 platforms = platforms.linux; 89 }; 90}