git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #145595 from dotlambda/graphviz-0.18
commit27ee289dcf2b9bac64dfd538f70035ac2fddb3d3 authorSandro <sandro.jaeckel@gmail.com> dateFri 12 Nov 2021, 15:55 (5 years ago) parent82a73efb534b85
3 files changed+94−101
pkgs/development/python-modules/graphviz/default.nix+5−3 pkgs/development/python-modules/graphviz/hardcode-graphviz-path.patch−98 pkgs/development/python-modules/graphviz/paths.patch+89
pkgs/development/python-modules/graphviz/default.nix+5−3
@@ -4,6 +4,7 @@
44, fetchFromGitHub
55, substituteAll
66, graphviz
7+, xdg-utils
78, makeFontsConf
89, freefont_ttf
910, mock
@@ -13,7 +14,7 @@
1314
1415buildPythonPackage rec {
1516 pname = "graphviz";
16− version = "0.17";
17+ version = "0.18";
1718
1819 disabled = pythonOlder "3.6";
1920
@@ -22,13 +23,14 @@ buildPythonPackage rec {
2223 owner = "xflr6";
2324 repo = "graphviz";
2425 rev = version;
25− sha256 = "sha256-K6z2C7hQH2A9bqgRR4MRqxVAH/k2NQBEelb2/6KDUr0=";
26+ sha256 = "sha256-K98CwG+V+EFwzyawVjRwVhbX2FVfoX7dCAD5PXAWTq8=";
2627 };
2728
2829 patches = [
2930 (substituteAll {
30− src = ./hardcode-graphviz-path.patch;
31+ src = ./paths.patch;
3132 inherit graphviz;
33+ xdgutils = xdg-utils;
3234 })
3335 ];
3436
pkgs/development/python-modules/graphviz/hardcode-graphviz-path.patchdeleted−98
@@ -1,98 +0,0 @@
1−diff --git a/graphviz/backend.py b/graphviz/backend.py
2−index b66e616..3da4ef0 100644
3−--- a/graphviz/backend.py
4−+++ b/graphviz/backend.py
5−@@ -124,7 +124,7 @@ def command(engine: str, format_: str, filepath=None,
6− raise ValueError(f'unknown formatter: {formatter!r}')
7−
8− output_format = [f for f in (format_, renderer, formatter) if f is not None]
9−- cmd = ['dot', '-K%s' % engine, '-T%s' % ':'.join(output_format)]
10−+ cmd = ['@graphviz@/bin/dot', '-K%s' % engine, '-T%s' % ':'.join(output_format)]
11−
12− if filepath is None:
13− rendered = None
14−@@ -297,7 +297,7 @@ def unflatten(source: str,
15− if fanout and stagger is None:
16− raise RequiredArgumentError('fanout given without stagger')
17−
18−- cmd = ['unflatten']
19−+ cmd = ['@graphviz@/bin/unflatten']
20− if stagger is not None:
21− cmd += ['-l', str(stagger)]
22− if fanout:
23−@@ -332,7 +332,7 @@ def version() -> typing.Tuple[int, ...]:
24− Graphviz Release version entry format:
25− https://gitlab.com/graphviz/graphviz/-/blob/f94e91ba819cef51a4b9dcb2d76153684d06a913/gen_version.py#L17-20
26− """
27−- cmd = ['dot', '-V']
28−+ cmd = ['@graphviz@/bin/dot', '-V']
29− out, _ = run(cmd, check=True, encoding='ascii',
30− stdout=subprocess.PIPE,
31− stderr=subprocess.STDOUT)
32−diff --git a/tests/test_backend.py b/tests/test_backend.py
33−index e0a0e1c..681f178 100644
34−--- a/tests/test_backend.py
35−+++ b/tests/test_backend.py
36−@@ -54,7 +54,7 @@ def test_run_encoding_mocked(mocker, Popen, input='sp\xe4m', encoding='utf-8'):
37− m.decode.assert_called_once_with(encoding)
38−
39−
40−-@pytest.mark.exe
41−+@pytest.mark.skip(reason='empty $PATH has no effect')
42− @pytest.mark.usefixtures('empty_path')
43− @pytest.mark.parametrize('func, args', [
44− (render, ['dot', 'pdf', 'nonfilepath']),
45−@@ -148,7 +148,7 @@ def test_render_mocked(capsys, mocker, Popen, quiet): # noqa: N803
46−
47− assert render('dot', 'pdf', 'nonfilepath', quiet=quiet) == 'nonfilepath.pdf'
48−
49−- Popen.assert_called_once_with(['dot', '-Kdot', '-Tpdf', '-O', 'nonfilepath'],
50−+ Popen.assert_called_once_with(['@graphviz@/bin/dot', '-Kdot', '-Tpdf', '-O', 'nonfilepath'],
51− stdout=subprocess.PIPE,
52− stderr=subprocess.PIPE,
53− cwd=None, startupinfo=mocker.ANY)
54−@@ -211,7 +211,7 @@ def test_pipe_pipe_invalid_data_mocked(mocker, Popen, quiet): # noqa: N803
55− assert e.value.stdout is out
56− e.value.stdout = mocker.sentinel.new_stdout
57− assert e.value.stdout is mocker.sentinel.new_stdout
58−- Popen.assert_called_once_with(['dot', '-Kdot', '-Tpng'],
59−+ Popen.assert_called_once_with(['@graphviz@/bin/dot', '-Kdot', '-Tpng'],
60− stdin=subprocess.PIPE,
61− stdout=subprocess.PIPE,
62− stderr=subprocess.PIPE,
63−@@ -231,7 +231,7 @@ def test_pipe_mocked(capsys, mocker, Popen, quiet): # noqa: N803
64−
65− assert pipe('dot', 'png', b'nongraph', quiet=quiet) == b'stdout'
66−
67−- Popen.assert_called_once_with(['dot', '-Kdot', '-Tpng'],
68−+ Popen.assert_called_once_with(['@graphviz@/bin/dot', '-Kdot', '-Tpng'],
69− stdin=subprocess.PIPE,
70− stdout=subprocess.PIPE,
71− stderr=subprocess.PIPE,
72−@@ -259,7 +259,7 @@ def test_unflatten_mocked(capsys, mocker, Popen):
73− proc.communicate.return_value = (b'nonresult', b'')
74−
75− assert unflatten('nonsource') == 'nonresult'
76−- Popen.assert_called_once_with(['unflatten'],
77−+ Popen.assert_called_once_with(['@graphviz@/bin/unflatten'],
78− stdin=subprocess.PIPE,
79− stdout=subprocess.PIPE,
80− stderr=subprocess.PIPE,
81−@@ -290,7 +290,7 @@ def test_version_parsefail_mocked(mocker, Popen): # noqa: N803
82− with pytest.raises(RuntimeError, match=r'nonversioninfo'):
83− version()
84−
85−- Popen.assert_called_once_with(['dot', '-V'],
86−+ Popen.assert_called_once_with(['@graphviz@/bin/dot', '-V'],
87− stdout=subprocess.PIPE,
88− stderr=subprocess.STDOUT,
89− startupinfo=mocker.ANY)
90−@@ -312,7 +312,7 @@ def test_version_mocked(mocker, Popen, stdout, expected): # noqa: N803
91−
92− assert version() == expected
93−
94−- Popen.assert_called_once_with(['dot', '-V'],
95−+ Popen.assert_called_once_with(['@graphviz@/bin/dot', '-V'],
96− stdout=subprocess.PIPE,
97− stderr=subprocess.STDOUT,
98− startupinfo=mocker.ANY)
pkgs/development/python-modules/graphviz/paths.patchnew file+89
@@ -0,0 +1,89 @@
1+diff --git a/graphviz/backend/dot_command.py b/graphviz/backend/dot_command.py
2+index d1903e6..6470d11 100644
3+--- a/graphviz/backend/dot_command.py
4++++ b/graphviz/backend/dot_command.py
5+@@ -10,7 +10,7 @@ from . import parameters
6+ __all__ = ['command']
7+
8+ #: :class:`pathlib.Path` of layout command (``Path('dot')``).
9+-DOT_BINARY = pathlib.Path('dot')
10++DOT_BINARY = pathlib.Path('@graphviz@/bin/dot')
11+
12+
13+ def command(engine: str, format_: str, *,
14+diff --git a/graphviz/backend/unflattening.py b/graphviz/backend/unflattening.py
15+index 5ed25d6..8d2faf8 100644
16+--- a/graphviz/backend/unflattening.py
17++++ b/graphviz/backend/unflattening.py
18+@@ -11,7 +11,7 @@ from . import execute
19+ __all__ = ['unflatten']
20+
21+ #: :class:`pathlib.Path` of unflatten command (``Path('unflatten')``).
22+-UNFLATTEN_BINARY = pathlib.Path('unflatten')
23++UNFLATTEN_BINARY = pathlib.Path('@graphviz@/bin/unflatten')
24+
25+
26+ def unflatten(source: str,
27+diff --git a/graphviz/backend/viewing.py b/graphviz/backend/viewing.py
28+index 6d4a4d1..2cc6cd8 100644
29+--- a/graphviz/backend/viewing.py
30++++ b/graphviz/backend/viewing.py
31+@@ -54,7 +54,7 @@ def view_darwin(filepath, *, quiet: bool) -> None:
32+ @tools.attach(view, 'freebsd')
33+ def view_unixoid(filepath, *, quiet: bool) -> None:
34+ """Open filepath in the user's preferred application (linux, freebsd)."""
35+- cmd = ['xdg-open', filepath]
36++ cmd = ['@xdgutils@/bin/xdg-open', filepath]
37+ log.debug('view: %r', cmd)
38+ kwargs = {'stderr': subprocess.DEVNULL} if quiet else {}
39+ subprocess.Popen(cmd, **kwargs)
40+diff --git a/tests/_common.py b/tests/_common.py
41+index ab93461..7eaca89 100644
42+--- a/tests/_common.py
43++++ b/tests/_common.py
44+@@ -10,7 +10,7 @@ __all__ = ['EXPECTED_DOT_BINARY', 'EXPECTED_DEFAULT_ENCODING',
45+ 'as_cwd',
46+ 'check_startupinfo', 'StartupinfoMatcher']
47+
48+-EXPECTED_DOT_BINARY = pathlib.Path('dot')
49++EXPECTED_DOT_BINARY = pathlib.Path('@graphviz@/bin/dot')
50+
51+ EXPECTED_DEFAULT_ENCODING = 'utf-8'
52+
53+diff --git a/tests/backend/test_execute.py b/tests/backend/test_execute.py
54+index 05d6525..78484cb 100644
55+--- a/tests/backend/test_execute.py
56++++ b/tests/backend/test_execute.py
57+@@ -57,6 +57,7 @@ def test_run_check_input_lines_mocked(mocker, sentinel, mock_popen,
58+ mock_sys_stderr.flush.assert_called_once_with()
59+
60+
61++@pytest.mark.skip(reason='empty $PATH has no effect')
62+ @pytest.mark.usefixtures('empty_path')
63+ @pytest.mark.parametrize(
64+ 'func, args',
65+diff --git a/tests/backend/test_unflattening.py b/tests/backend/test_unflattening.py
66+index 033a4d2..7d52689 100644
67+--- a/tests/backend/test_unflattening.py
68++++ b/tests/backend/test_unflattening.py
69+@@ -8,7 +8,7 @@ import graphviz
70+
71+ import _common
72+
73+-EXPECTED_UNFLATTEN_BINARY = pathlib.Path('unflatten')
74++EXPECTED_UNFLATTEN_BINARY = pathlib.Path('@graphviz@/bin/unflatten')
75+
76+
77+ @pytest.mark.exe
78+diff --git a/tests/backend/test_viewing.py b/tests/backend/test_viewing.py
79+index f5acddb..6b34884 100644
80+--- a/tests/backend/test_viewing.py
81++++ b/tests/backend/test_viewing.py
82+@@ -25,6 +25,6 @@ def test_view(mocker, mock_platform, mock_popen, mock_startfile, quiet):
83+ if mock_platform == 'darwin':
84+ mock_popen.assert_called_once_with(['open', 'nonfilepath'], **kwargs)
85+ elif mock_platform in ('linux', 'freebsd'):
86+- mock_popen.assert_called_once_with(['xdg-open', 'nonfilepath'], **kwargs)
87++ mock_popen.assert_called_once_with(['@xdgutils@/bin/xdg-open', 'nonfilepath'], **kwargs)
88+ else:
89+ raise RuntimeError