1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fontconfig,
6 graphviz,
7 poetry-core,
8 pytest7CheckHook,
9 pythonOlder,
10 six,
11 substituteAll,
12 withGraphviz ? true,
13}:
14
15buildPythonPackage rec {
16 pname = "anytree";
17 version = "2.12.1";
18 format = "pyproject";
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "c0fec0de";
24 repo = "anytree";
25 rev = "refs/tags/${version}";
26 hash = "sha256-5HU8kR3B2RHiGBraQ2FTgVtGHJi+Lha9U/7rpNsYCCI=";
27 };
28
29 patches = lib.optionals withGraphviz [
30 (substituteAll {
31 src = ./graphviz.patch;
32 inherit graphviz;
33 })
34 ];
35
36 nativeBuildInputs = [ poetry-core ];
37
38 propagatedBuildInputs = [ six ];
39
40 nativeCheckInputs = [ pytest7CheckHook ];
41
42 # Tests print “Fontconfig error: Cannot load default config file”
43 preCheck = lib.optionalString withGraphviz ''
44 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
45 '';
46
47 # Circular dependency anytree → graphviz → pango → glib → gtk-doc → anytree
48 doCheck = withGraphviz;
49
50 pythonImportsCheck = [ "anytree" ];
51
52 meta = with lib; {
53 description = "Powerful and Lightweight Python Tree Data Structure";
54 homepage = "https://github.com/c0fec0de/anytree";
55 changelog = "https://github.com/c0fec0de/anytree/releases/tag/${version}";
56 license = licenses.asl20;
57 maintainers = with maitnainers; [ ];
58 };
59}