2019-04-12 17:17:36 +01:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2020-11-26 21:21:44 +00:00
|
|
|
, bazel_0_26
|
2019-04-12 17:17:36 +01:00
|
|
|
, buildBazelPackage
|
|
|
|
, buildPythonPackage
|
|
|
|
, git
|
|
|
|
, python
|
|
|
|
, six
|
|
|
|
, absl-py
|
|
|
|
, semantic-version
|
|
|
|
, contextlib2
|
|
|
|
, wrapt
|
|
|
|
, tensorflow
|
|
|
|
, tensorflow-probability
|
2019-06-21 17:23:50 +01:00
|
|
|
, tensorflow-estimator
|
2019-04-12 17:17:36 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-06-26 11:26:39 +01:00
|
|
|
version = "1.33";
|
2019-04-12 17:17:36 +01:00
|
|
|
|
|
|
|
# first build all binaries and generate setup.py using bazel
|
2019-08-13 22:52:01 +01:00
|
|
|
bazel-build = buildBazelPackage {
|
2020-11-26 21:21:44 +00:00
|
|
|
bazel = bazel_0_26;
|
|
|
|
|
2019-04-12 17:17:36 +01:00
|
|
|
name = "dm-sonnet-bazel-${version}";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "deepmind";
|
|
|
|
repo = "sonnet";
|
|
|
|
rev = "v${version}";
|
2019-06-26 11:26:39 +01:00
|
|
|
sha256 = "1nqsja1s8jrkq6v1whgh7smk17313mjr9vs3k5c1m8px4yblzhqc";
|
2019-04-12 17:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
git # needed to fetch the bazel deps (protobuf in particular)
|
|
|
|
];
|
|
|
|
|
|
|
|
# see https://github.com/deepmind/sonnet/blob/master/docs/INSTALL.md
|
|
|
|
bazelTarget = ":install";
|
|
|
|
|
|
|
|
fetchAttrs = {
|
2020-11-26 21:21:44 +00:00
|
|
|
sha256 = "09dzxs2v5wpiaxrz7qj257q1fbx0gxwbk0jyx58n81m5kys7yj9k";
|
2019-04-12 17:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildAttrs = {
|
|
|
|
preBuild = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# do not generate a wheel, instead just copy the generated files to $out to be installed by buildPythonPackage
|
|
|
|
sed -i 's,.*bdist_wheel.*,cp -rL . "$out"; exit 0,' bazel-bin/install
|
|
|
|
|
|
|
|
# the target directory "dist" does not actually matter since we're not generating a wheel
|
|
|
|
bazel-bin/install dist
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# now use pip to install the package prepared by bazel
|
2019-08-13 22:52:01 +01:00
|
|
|
in buildPythonPackage {
|
2019-04-12 17:17:36 +01:00
|
|
|
pname = "dm-sonnet";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = bazel-build;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
six
|
|
|
|
absl-py
|
|
|
|
semantic-version
|
|
|
|
contextlib2
|
|
|
|
wrapt
|
|
|
|
tensorflow
|
|
|
|
tensorflow-probability
|
2019-06-21 17:23:50 +01:00
|
|
|
tensorflow-estimator
|
2019-04-12 17:17:36 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# not sure how to properly run the real test suite -- through bazel?
|
|
|
|
checkPhase = ''
|
|
|
|
${python.interpreter} -c "import sonnet"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "TensorFlow-based neural network library";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://sonnet.dev";
|
2019-04-12 17:17:36 +01:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ timokau ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|