diff --git a/pkgs/development/python-modules/anytree/default.nix b/pkgs/development/python-modules/anytree/default.nix new file mode 100644 index 000000000000..3821fea2446c --- /dev/null +++ b/pkgs/development/python-modules/anytree/default.nix @@ -0,0 +1,63 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, substituteAll +, fetchpatch +, nose +, six +, graphviz +, fontconfig +}: + +buildPythonPackage rec { + pname = "anytree"; + version = "2.6.0"; + + src = fetchFromGitHub { + owner = "c0fec0de"; + repo = pname; + rev = version; + sha256 = "1k3yj9h3ssjlz57r4g1qzxvprxjp7n92vms9fv0d46pigylxm5i3"; + }; + + patches = [ + (substituteAll { + src = ./graphviz.patch; + inherit graphviz; + }) + # Fix tests python3.7 + # See: https://github.com/c0fec0de/anytree/pull/85 + (fetchpatch { + url = "https://github.com/c0fec0de/anytree/commit/dd1b3d325546fef7436711e4cfea9a5fb61daaf8.patch"; + sha256 = "1dpa2jh2kakfaapnqrz03frb67q5fwxzc8c70i6nv1b01i9xw0bn"; + }) + ]; + + checkInputs = [ + nose + ]; + + propagatedBuildInputs = [ + six + ]; + + # Fontconfig error: Cannot load default config file + preCheck = '' + export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf + ''; + + checkPhase = '' + runHook preCheck + + nosetests + + runHook postCheck + ''; + + meta = with lib; { + description = "Powerful and Lightweight Python Tree Data Structure"; + homepage = https://github.com/c0fec0de/anytree; + license = licenses.asl20; + maintainers = [ maintainers.worldofpeace ]; + }; +} diff --git a/pkgs/development/python-modules/anytree/graphviz.patch b/pkgs/development/python-modules/anytree/graphviz.patch new file mode 100644 index 000000000000..583b60444e35 --- /dev/null +++ b/pkgs/development/python-modules/anytree/graphviz.patch @@ -0,0 +1,13 @@ +diff --git a/anytree/exporter/dotexporter.py b/anytree/exporter/dotexporter.py +index 9c10a68..209a952 100644 +--- a/anytree/exporter/dotexporter.py ++++ b/anytree/exporter/dotexporter.py +@@ -228,7 +228,7 @@ class DotExporter(object): + for line in self: + dotfile.write(("%s\n" % line).encode("utf-8")) + dotfile.flush() +- cmd = ["dot", dotfilename, "-T", fileformat, "-o", filename] ++ cmd = ["@graphviz@/bin/dot", dotfilename, "-T", fileformat, "-o", filename] + check_call(cmd) + try: + remove(dotfilename) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a70f5309d4d3..7dae4ff91aff 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -181,6 +181,10 @@ in { ansicolor = callPackage ../development/python-modules/ansicolor { }; + anytree = callPackage ../development/python-modules/anytree { + inherit (pkgs) graphviz; + }; + aplpy = callPackage ../development/python-modules/aplpy { }; argon2_cffi = callPackage ../development/python-modules/argon2_cffi { };