Skip to content

Commit 99222ba

Browse files
committed
Fix dep-graph command: outdated import
The `--dep-graph` command uses `graphviz-python` (`import gv`) to convert a dot-graph into an image file. This library seems outdated. In pip it is now called `graphviz` and the API is slightly different. The docs already refer to it. This commit fixes the import and the function that renders the graph image.
1 parent a42e25b commit 99222ba

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

easybuild/framework/easyconfig/tools.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,7 @@
8080
# https://pypi.python.org/pypi/python-graph-dot
8181
import pygraph.readwrite.dot as dot
8282
# graphviz (used for creating dependency graph images)
83-
sys.path.append('..')
84-
sys.path.append('/usr/lib/graphviz/python/')
85-
sys.path.append('/usr/lib64/graphviz/python/')
86-
# Python bindings to Graphviz (http://www.graphviz.org/),
87-
# see https://pypi.python.org/pypi/graphviz-python
88-
# graphviz-python (yum) or python-pygraphviz (apt-get)
89-
# or brew install graphviz --with-bindings (OS X)
90-
import gv
83+
import graphviz
9184
except ImportError:
9285
pass
9386

@@ -244,13 +237,14 @@ def _dep_graph_dump(dgr, filename):
244237
return _dep_graph_gv(dottxt, filename)
245238

246239

247-
@only_if_module_is_available('gv', pkgname='graphviz-python')
240+
@only_if_module_is_available('graphviz', pkgname='graphviz')
248241
def _dep_graph_gv(dottxt, filename):
249242
"""Render dependency graph to file using graphviz."""
250243
# try and render graph in specified file format
251-
gvv = gv.readstring(dottxt)
252-
if gv.layout(gvv, 'dot') is not False:
253-
return gv.render(gvv, os.path.splitext(filename)[-1], filename)
244+
gvv = graphviz.Source(dottxt)
245+
if gvv.pipe():
246+
name, ext = os.path.splitext(filename)
247+
return gvv.render(filename=name, format=ext[1:], cleanup=True)
254248

255249

256250
def get_paths_for(subdir=EASYCONFIGS_PKG_SUBDIR, robot_path=None):

easybuild/tools/systemtools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
'autopep8': (None, "auto-formatting for dumped easyconfigs"),
203203
'GC3Pie': ('gc3libs', "backend for --job"),
204204
'GitPython': ('git', "GitHub integration + using Git repository as easyconfigs archive"),
205-
'graphviz-python': ('gv', "rendering dependency graph with Graphviz: --dep-graph"),
205+
'graphviz': ('graphviz', "rendering dependency graph with Graphviz: --dep-graph"),
206206
'keyring': (None, "storing GitHub token"),
207207
'pbs-python': ('pbs', "using Torque as --job backend"),
208208
'pycodestyle': (None, "code style checking: --check-style, --check-contrib"),

0 commit comments

Comments
 (0)