Skip to content

Commit 3940f09

Browse files
authored
Merge pull request #4891 from lorisercole/fix/dep-graph
Fix `--dep-graph` by using `graphviz` Python package
2 parents 0e469b0 + 99222ba commit 3940f09

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
@@ -207,7 +207,7 @@
207207
'autopep8': (None, "auto-formatting for dumped easyconfigs"),
208208
'GC3Pie': ('gc3libs', "backend for --job"),
209209
'GitPython': ('git', "GitHub integration + using Git repository as easyconfigs archive"),
210-
'graphviz-python': ('gv', "rendering dependency graph with Graphviz: --dep-graph"),
210+
'graphviz': ('graphviz', "rendering dependency graph with Graphviz: --dep-graph"),
211211
'keyring': (None, "storing GitHub token"),
212212
'pbs-python': ('pbs', "using Torque as --job backend"),
213213
'pycodestyle': (None, "code style checking: --check-style, --check-contrib"),

0 commit comments

Comments
 (0)