summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/anytree/default.nix
blob: 1781088fe5afef3c9c5b27c353a8a8831ce1c2c2 (plain)
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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  graphviz,

  # build-system
  pdm-backend,

  # tests
  pytest-cov-stub,
  pytestCheckHook,
  pyyaml,
  test2ref,
  fontconfig,
}:

buildPythonPackage rec {
  pname = "anytree";
  version = "2.13.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "c0fec0de";
    repo = "anytree";
    tag = version;
    hash = "sha256-kFNYJMWagpqixs84+AaNkh/28asLBJhibTP8LEEe4XY=";
  };

  postPatch = ''
    substituteInPlace src/anytree/exporter/dotexporter.py \
      --replace-fail \
        'cmd = ["dot"' \
        'cmd = ["${lib.getExe' graphviz "dot"}"'
  '';

  build-system = [ pdm-backend ];

  nativeCheckInputs = [
    pytest-cov-stub
    pytestCheckHook
    pyyaml
    test2ref
  ];

  # Tests print “Fontconfig error: Cannot load default config file”
  preCheck = ''
    export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
  '';

  pythonImportsCheck = [ "anytree" ];

  meta = {
    description = "Powerful and Lightweight Python Tree Data Structure";
    homepage = "https://github.com/c0fec0de/anytree";
    changelog = "https://github.com/c0fec0de/anytree/releases/tag/${version}";
    license = lib.licenses.asl20;
    maintainers = [ ];
  };
}