1{ lib
2, buildPythonPackage
3, fetchPypi
4, pythonOlder
5, substituteAll
6, six
7, withGraphviz ? true
8, graphviz
9, fontconfig
10# Tests
11, pytestCheckHook
12, nose
13}:
14
15buildPythonPackage rec {
16 pname = "anytree";
17 version = "2.8.0";
18
19 src = fetchPypi {
20 inherit pname version;
21 sha256 = "3f0f93f355a91bc3e6245319bf4c1d50e3416cc7a35cc1133c1ff38306bbccab";
22 };
23
24 patches = lib.optionals withGraphviz [
25 (substituteAll {
26 src = ./graphviz.patch;
27 inherit graphviz;
28 })
29 ];
30
31 propagatedBuildInputs = [
32 six
33 ];
34
35 # tests print “Fontconfig error: Cannot load default config file”
36 preCheck = lib.optionalString withGraphviz ''
37 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
38 '';
39
40 # circular dependency anytree → graphviz → pango → glib → gtk-doc → anytree
41 doCheck = withGraphviz;
42
43 checkInputs = [ pytestCheckHook nose ];
44
45 pytestFlagsArray = lib.optionals (pythonOlder "3.4") [
46 # Use enums, which aren't available pre-python3.4
47 "--ignore=tests/test_resolver.py"
48 "--ignore=tests/test_search.py"
49 ];
50
51 meta = with lib; {
52 description = "Powerful and Lightweight Python Tree Data Structure";
53 homepage = "https://github.com/c0fec0de/anytree";
54 license = licenses.asl20;
55 maintainers = [ ];
56 };
57}