about summary refs log tree commit diff
path: root/pkgs/development/python-modules/dm-tree/default.nix
blob: 6062d202a3ce7093f22a0b6efd415ac05f5f6643 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  lib,
  buildPythonPackage,
  fetchpatch,
  fetchFromGitHub,
  stdenv,

  # nativeBuildInputs
  cmake,
  pybind11,

  # buildInputs
  abseil-cpp,

  # build-system
  setuptools,

  # checks
  absl-py,
  attrs,
  numpy,
  wrapt,
}:
let
  patchCMakeAbseil = fetchpatch {
    name = "0001-don-t-rebuild-abseil.patch";
    url = "https://raw.githubusercontent.com/conda-forge/dm-tree-feedstock/93a91aa2c13240cecf88133e2885ade9121b464a/recipe/patches/0001-don-t-rebuild-abseil.patch";
    hash = "sha256-bho7lXAV5xHkPmWy94THJtx+6i+px5w6xKKfThvBO/M=";
  };
  patchCMakePybind = fetchpatch {
    name = "0002-don-t-fetch-pybind11.patch";
    url = "https://raw.githubusercontent.com/conda-forge/dm-tree-feedstock/93a91aa2c13240cecf88133e2885ade9121b464a/recipe/patches/0002-don-t-fetch-pybind11.patch";
    hash = "sha256-41XIouQ4Fm1yewaxK9erfcnkGBS6vgdvMm/DyF0rsKg=";
  };
in
buildPythonPackage rec {
  pname = "dm-tree";
  version = "0.1.8";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "deepmind";
    repo = "tree";
    rev = "refs/tags/${version}";
    hash = "sha256-VvSJTuEYjIz/4TTibSLkbg65YmcYqHImTHOomeorMJc=";
  };

  patches = [
    patchCMakeAbseil
    patchCMakePybind
  ] ++ (lib.optional stdenv.isDarwin ./0003-don-t-configure-apple.patch);

  dontUseCmakeConfigure = true;

  nativeBuildInputs = [
    cmake
    pybind11
  ];

  buildInputs = [
    abseil-cpp
    pybind11
  ];

  build-system = [ setuptools ];

  nativeCheckInputs = [
    absl-py
    attrs
    numpy
    wrapt
  ];

  pythonImportsCheck = [ "tree" ];

  meta = {
    description = "Tree is a library for working with nested data structures";
    homepage = "https://github.com/deepmind/tree";
    changelog = "https://github.com/google-deepmind/tree/releases/tag/${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      samuela
      ndl
    ];
  };
}