1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 replaceVars,
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 tag = version;
31 hash = "sha256-IqjqcBEL4BK/VfRjdxJ9t/DkG8OMAoXJxbW5JXpALuw=";
32 };
33
34 patches = [
35 (replaceVars ./paths.patch {
36 graphviz = graphviz-nox;
37 xdgutils = xdg-utils;
38 })
39 ];
40
41 postPatch = ''
42 sed -i "/--cov/d" setup.cfg
43 '';
44
45 # Fontconfig error: Cannot load default config file
46 FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ freefont_ttf ]; };
47
48 build-system = [ setuptools ];
49
50 nativeCheckInputs = [
51 mock
52 pytest_7
53 pytest-mock
54 ];
55
56 checkPhase = ''
57 runHook preCheck
58
59 HOME=$TMPDIR ${python.interpreter} run-tests.py
60
61 runHook postCheck
62 '';
63
64 # Too many failures due to attempting to connect to com.apple.fonts daemon
65 doCheck = !stdenv.hostPlatform.isDarwin;
66
67 meta = with lib; {
68 description = "Simple Python interface for Graphviz";
69 homepage = "https://github.com/xflr6/graphviz";
70 changelog = "https://github.com/xflr6/graphviz/blob/${src.rev}/CHANGES.rst";
71 license = licenses.mit;
72 maintainers = with maintainers; [ dotlambda ];
73 };
74}