1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 substituteAll,
8 graphviz-nox,
9 xdg-utils,
10 makeFontsConf,
11 freefont_ttf,
12 setuptools,
13 mock,
14 pytest_7,
15 pytest-mock,
16 python,
17}:
18
19buildPythonPackage rec {
20 pname = "graphviz";
21 version = "0.20.3";
22 pyproject = true;
23
24 disabled = pythonOlder "3.8";
25
26 # patch does not apply to PyPI tarball due to different line endings
27 src = fetchFromGitHub {
28 owner = "xflr6";
29 repo = "graphviz";
30 rev = "refs/tags/${version}";
31 hash = "sha256-IqjqcBEL4BK/VfRjdxJ9t/DkG8OMAoXJxbW5JXpALuw=";
32 };
33
34 patches = [
35 (substituteAll {
36 src = ./paths.patch;
37 graphviz = graphviz-nox;
38 xdgutils = xdg-utils;
39 })
40 ];
41
42 postPatch = ''
43 sed -i "/--cov/d" setup.cfg
44 '';
45
46 # Fontconfig error: Cannot load default config file
47 FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ freefont_ttf ]; };
48
49 build-system = [ setuptools ];
50
51 nativeCheckInputs = [
52 mock
53 pytest_7
54 pytest-mock
55 ];
56
57 checkPhase = ''
58 runHook preCheck
59
60 HOME=$TMPDIR ${python.interpreter} run-tests.py
61
62 runHook postCheck
63 '';
64
65 # Too many failures due to attempting to connect to com.apple.fonts daemon
66 doCheck = !stdenv.isDarwin;
67
68 meta = with lib; {
69 description = "Simple Python interface for Graphviz";
70 homepage = "https://github.com/xflr6/graphviz";
71 changelog = "https://github.com/xflr6/graphviz/blob/${src.rev}/CHANGES.rst";
72 license = licenses.mit;
73 maintainers = with maintainers; [ dotlambda ];
74 };
75}