Commit e9ce1c21 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files

python312Packages.dm-sonnet: cleanup, fix build

parent 16ed352d
Loading
Loading
Loading
Loading
+43 −20
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  click,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  dm-tree,
  docutils,
  etils,
  fetchFromGitHub,
  fetchpatch,
  numpy,
  pythonOlder,
  tabulate,
  wrapt,

  # tests
  click,
  docutils,
  keras,
  pytestCheckHook,
  tensorflow,
  tensorflow-datasets,
  wrapt,
  tf-keras,
}:

buildPythonPackage rec {
  pname = "dm-sonnet";
  version = "2.0.2";
  format = "setuptools";

  disabled = pythonOlder "3.6";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "deepmind";
    repo = "sonnet";
    rev = "refs/tags/v${version}";
    tag = "v${version}";
    hash = "sha256-WkloUbqSyPG3cbLG8ktsjdluACkCbUZ7t6rYWst8rs8=";
  };

  patches = [
    (fetchpatch {
      name = "replace-np-bool-with-np-bool_.patch";
      url = "https://github.com/deepmind/sonnet/commit/df5d099d4557a9a81a0eb969e5a81ed917bcd612.patch";
      hash = "sha256-s7abl83osD4wa0ZhqgDyjqQ3gagwGYCdQifwFqhNp34=";
    })
  build-system = [
    setuptools
  ];

  propagatedBuildInputs = [
  dependencies = [
    dm-tree
    etils
    numpy
@@ -52,16 +54,37 @@ buildPythonPackage rec {
  nativeCheckInputs = [
    click
    docutils
    keras
    pytestCheckHook
    tensorflow
    tensorflow-datasets
    tf-keras
  ];

  # ImportError: `keras.optimizers.legacy` is not supported in Keras 3
  preCheck = ''
    export TF_USE_LEGACY_KERAS=True
  '';

  disabledTests = [
    # AssertionError: 2 != 0 : 2 doctests failed
    "test_doctest_sonnet.functional"

    # AssertionError: Not equal to tolerance
    "testComputationAgainstNumPy1"

    # tensorflow.python.framework.errors_impl.InvalidArgumentError: cannot compute MatMul as input #1(zero-based) was expected to be a float tensor but is a half tensor [Op:MatMul]
    "testComputationAgainstNumPy0"
    "testComputationAgainstNumPy1"
  ];

  pythonImportsCheck = [ "sonnet" ];

  meta = with lib; {
  meta = {
    description = "Library for building neural networks in TensorFlow";
    homepage = "https://github.com/deepmind/sonnet";
    license = licenses.asl20;
    maintainers = with maintainers; [ onny ];
    changelog = "https://github.com/google-deepmind/sonnet/releases/tag/v${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ onny ];
  };
}