From 6d355e44f8274b8c0142d50bfdaec168db3ebd24 Mon Sep 17 00:00:00 2001 From: "Robert K. Bell" Date: Tue, 29 Dec 2020 20:48:13 +1100 Subject: [PATCH] xdot: fix tests `nix-shell -p xdot` was failing, with an error like: builder for '/nix/store/n3yjqssn531c52sbkmpqvczmy5c0lm8n-python3.8-xdot-1.2.drv' failed with exit code 1; last 10 log lines: import numpy ModuleNotFoundError: No module named 'numpy' Adding numpy uncovered another error, about not being able to initialize gtk: error: Test failed: error: --- Error -------------------------------------------------------------------------------------------------------------------------------------------- nix-shell builder for '/nix/store/brz6q1ri12z51z3l2p5d6ny2jsf3qkjg-python3.8-xdot-1.2.drv' failed with exit code 1; last 10 log lines: raise RuntimeError( RuntimeError: Gtk couldn't be initialized. Use Gtk.init_check() if you want to handle this case. --- pkgs/development/python-modules/xdot/default.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/xdot/default.nix b/pkgs/development/python-modules/xdot/default.nix index e8b95e5d09cc..75d090699a47 100644 --- a/pkgs/development/python-modules/xdot/default.nix +++ b/pkgs/development/python-modules/xdot/default.nix @@ -1,5 +1,5 @@ -{ lib, buildPythonPackage, fetchPypi, isPy3k -, wrapGAppsHook, gobject-introspection, pygobject3, graphviz, gtk3 }: +{ lib, buildPythonPackage, fetchPypi, isPy3k, python3, xvfb_run, stdenv +, wrapGAppsHook, gobject-introspection, pygobject3, graphviz, gtk3, numpy }: buildPythonPackage rec { pname = "xdot"; @@ -11,9 +11,16 @@ buildPythonPackage rec { }; disabled = !isPy3k; - nativeBuildInputs = [ wrapGAppsHook ]; - propagatedBuildInputs = [ gobject-introspection pygobject3 graphviz gtk3 ]; + propagatedBuildInputs = [ gobject-introspection pygobject3 graphviz gtk3 numpy ]; + checkInputs = [ xvfb_run ]; + + checkPhase = '' + xvfb-run -s '-screen 0 800x600x24' ${python3.interpreter} nix_run_setup test + ''; + + # https://github.com/NixOS/nixpkgs/pull/107872#issuecomment-752175866 + doCheck = stdenv.isLinux; meta = with lib; { description = "An interactive viewer for graphs written in Graphviz's dot";