Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / graphviz.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
5 ;;; Copyright © 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017 Gábor Boskovits <boskovits@gmail.com>
8 ;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
9 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages graphviz)
27 #:use-module (guix packages)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system python)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix utils)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages check)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages gd)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages gnome)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages image)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages swig)
50 #:use-module (gnu packages tcl)
51 #:use-module (gnu packages tex)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module ((guix licenses) #:prefix license:))
55
56 (define-public graphviz
57 (package
58 (name "graphviz")
59 (version "2.42.3")
60 (source (origin
61 (method url-fetch)
62 (uri (string-append
63 "https://www2.graphviz.org/Packages/stable/portable_source/"
64 "graphviz-" version ".tar.gz"))
65 (sha256
66 (base32
67 "1pbswjbx3fjdlsxcm7cmlsl5bvaa3d6gcnr0cr8x3c8pag13zbwg"))))
68 (build-system gnu-build-system)
69 (arguments
70 ;; FIXME: rtest/rtest.sh is a ksh script (!). Add ksh as an input.
71 '(#:tests? #f
72 #:phases
73 (modify-phases %standard-phases
74 (add-after 'install 'move-docs
75 (lambda* (#:key outputs #:allow-other-keys)
76 (let ((out (assoc-ref outputs "out"))
77 (doc (assoc-ref outputs "doc")))
78 (mkdir-p (string-append doc "/share/graphviz"))
79 (rename-file (string-append out "/share/graphviz/doc")
80 (string-append doc "/share/graphviz/doc"))
81 #t)))
82 (add-after 'move-docs 'move-guile-bindings
83 (lambda* (#:key outputs #:allow-other-keys)
84 (let* ((out (assoc-ref outputs "out"))
85 (lib (string-append out "/lib"))
86 (extdir (string-append lib
87 "/guile/2.0/extensions")))
88 (mkdir-p extdir)
89 (rename-file (string-append
90 lib "/graphviz/guile/libgv_guile.so")
91 (string-append extdir
92 "/libgv_guile.so"))
93 #t))))))
94 (inputs
95 `(("libXrender" ,libxrender)
96 ("libX11" ,libx11)
97 ("gts" ,gts)
98 ("gd" ,gd) ; FIXME: Our GD is too old
99 ("guile" ,guile-2.0) ;Guile bindings
100 ("swig" ,swig)
101 ("pango" ,pango)
102 ("fontconfig" ,fontconfig)
103 ("freetype" ,freetype)
104 ("libltdl" ,libltdl)
105 ("libXaw" ,libxaw)
106 ("expat" ,expat)
107 ("libjpeg" ,libjpeg-turbo)
108 ("libpng" ,libpng)))
109 (native-inputs
110 `(("bison" ,bison)
111 ("pkg-config" ,pkg-config)))
112 (outputs '("out" "doc")) ; 5 MiB of html + pdfs
113 (home-page "http://www.graphviz.org/")
114 (synopsis "Graph visualization software")
115 (description
116 "Graphviz is a graph visualization tool suite. Graph visualization is a
117 way of representing structural information as diagrams of abstract graphs and
118 networks. It has important applications in networking, bioinformatics,
119 software engineering, database and web design, machine learning, and in visual
120 interfaces for other technical domains.")
121 (license license:epl1.0)))
122
123 ;; Older Graphviz needed for pygraphviz. See
124 ;; https://github.com/pygraphviz/pygraphviz/issues/175
125 (define-public graphviz-2.38
126 ;; This commit corresponds to the changelog change for version 2.38.0.
127 ;; There are no tags.
128 (let ((commit "f54ac2c9313ae80ccf76ef4ac6aa9be820a23126")
129 (revision "1"))
130 (package (inherit graphviz)
131 (name "graphviz")
132 (version (git-version "2.38.0" revision commit))
133 (source (origin
134 (method git-fetch)
135 (uri (git-reference
136 (url "https://gitlab.com/graphviz/graphviz.git")
137 (commit commit)))
138 (file-name (git-file-name name version))
139 (sha256
140 (base32
141 "1vjg308gflmi1khgjmcj431cnkrlv12bg4cqah39mwhny92jy92x"))))
142 (arguments
143 (substitute-keyword-arguments (package-arguments graphviz)
144 ((#:phases phases)
145 `(modify-phases ,phases
146 (add-after 'unpack 'prepare-bootstrap
147 (lambda _
148 (substitute* "autogen.sh"
149 (("/bin/sh") (which "sh"))
150 (("\\$GRAPHVIZ_VERSION_DATE") "0"))
151 (setenv "CONFIG_SHELL" (which "sh"))
152 (setenv "SHELL" (which "sh"))
153
154 (map make-file-writable (find-files "." ".*"))
155 #t))
156 (replace 'bootstrap
157 (lambda _ (invoke (which "sh") "autogen.sh" "NOCONFIG") #t))))))
158 (native-inputs
159 `(("autoconf" ,autoconf)
160 ("automake" ,automake)
161 ("libtool" ,libtool)
162 ("flex" ,flex)
163 ("perl" ,perl)
164 ("tcl" ,tcl)
165 ,@(package-native-inputs graphviz))))))
166
167 (define-public python-graphviz
168 (package
169 (name "python-graphviz")
170 (version "0.13.2")
171 (source (origin
172 (method url-fetch)
173 (uri (pypi-uri "graphviz" version ".zip"))
174 (sha256
175 (base32
176 "009alrilzx0v7kl41khbq7k6k8b8pxyvbsi1b1ai933f6kpbxb30"))))
177 (build-system python-build-system)
178 (arguments
179 '(#:phases (modify-phases %standard-phases
180 (replace 'check
181 (lambda* (#:key tests #:allow-other-keys)
182 (if tests
183 (invoke "pytest" "-vv")
184 (format #t "test suite not run~%"))
185 #t)))))
186 (native-inputs
187 `(("unzip" ,unzip)
188
189 ;; For tests.
190 ("graphviz" ,graphviz)
191 ("python-mock" ,python-mock)
192 ("python-pytest" ,python-pytest)
193 ("python-pytest-cov" ,python-pytest-cov)
194 ("python-pytest-mock" ,python-pytest-mock)))
195 (home-page "https://github.com/xflr6/graphviz")
196 (synopsis "Simple Python interface for Graphviz")
197 (description
198 "This package provides a simple Python interface for the Graphviz graph
199 visualization tool suite.")
200 (license license:expat)))
201
202 (define-public python2-graphviz
203 (package-with-python2 python-graphviz))
204
205 (define-public python-pygraphviz
206 (package
207 (name "python-pygraphviz")
208 (version "1.5")
209 (source
210 (origin
211 (method git-fetch)
212 (uri (git-reference
213 (url "https://github.com/pygraphviz/pygraphviz.git")
214 (commit (string-append "pygraphviz-" version))))
215 (file-name (string-append "pygraphviz-" version "-checkout"))
216 (sha256
217 (base32
218 "1yldym38m8ckgflln83i88143pd9fjj1vfp23sq39fs6np5g0nzp"))))
219 (build-system python-build-system)
220 (arguments
221 `(#:configure-flags
222 (let ((graphviz (assoc-ref %build-inputs "graphviz")))
223 (list (string-append "--include-path=" graphviz "/include")
224 (string-append "--library-path=" graphviz "/lib")))))
225 (inputs
226 `(("graphviz" ,graphviz-2.38)))
227 (native-inputs
228 `(("python-nose" ,python-nose)
229 ("python-mock" ,python-mock)
230 ("python-doctest-ignore-unicode" ,python-doctest-ignore-unicode)))
231 (home-page "http://pygraphviz.github.io")
232 (synopsis "Python interface to Graphviz")
233 (description "PyGraphviz is a Python interface to the Graphviz graph
234 layout and visualization package. With PyGraphviz you can create, edit, read,
235 write, and draw graphs using Python to access the Graphviz graph data
236 structure and layout algorithms.")
237 (license license:bsd-3)))
238
239 (define-public gts
240 (package
241 (name "gts")
242 (version "0.7.6")
243 (source (origin
244 (method url-fetch)
245 (uri (string-append "mirror://sourceforge/gts/gts/" version
246 "/gts-" version ".tar.gz"))
247 (sha256
248 (base32
249 "07mqx09jxh8cv9753y2d2jsv7wp8vjmrd7zcfpbrddz3wc9kx705"))))
250 (build-system gnu-build-system)
251 (arguments
252 '(#:phases
253 (modify-phases %standard-phases
254 (add-before 'check 'pre-check
255 (lambda _
256 (chmod "test/boolean/test.sh" #o777)
257 #t)))
258
259 ;; Some data files used by the test suite are missing.
260 ;; See <http://sourceforge.net/p/gts/bugs/41/>.
261 #:tests? #f))
262 (native-inputs
263 `(("pkg-config" ,pkg-config)))
264 (propagated-inputs
265 ;; The gts.pc file has glib-2.0 as required.
266 `(("glib" ,glib)))
267 (home-page "http://gts.sourceforge.net/")
268
269 ;; Note: Despite the name, this is not official GNU software.
270 (synopsis "Triangulated Surface Library")
271 (description
272 "Library intended to provide a set of useful functions to deal with
273 3D surfaces meshed with interconnected triangles.")
274 (license license:lgpl2.0+)))
275
276 (define-public xdot
277 (package
278 (name "xdot")
279 (version "1.1")
280 (source
281 (origin
282 (method url-fetch)
283 (uri (pypi-uri "xdot" version))
284 (sha256
285 (base32
286 "0cr4rh7dz4dfzyxrk5pzhm0d15gkrgkfp3i5lw178xy81pc56p71"))))
287 (build-system python-build-system)
288 (arguments
289 `(#:phases
290 (modify-phases %standard-phases
291 ;; We wrap xdot, so that we don't propagate gtk+ and graphviz
292 (add-after 'install 'wrap
293 (lambda* (#:key inputs outputs #:allow-other-keys)
294 (wrap-program (string-append (assoc-ref outputs "out") "/bin/xdot")
295 `("GI_TYPELIB_PATH" ":" prefix
296 (,(string-append
297 (assoc-ref inputs "gtk+") "/lib/girepository-1.0"
298 ":" (assoc-ref inputs "pango") "/lib/girepository-1.0"
299 ":" (assoc-ref inputs "gdk-pixbuf") "/lib/girepository-1.0"
300 ":" (assoc-ref inputs "atk") "/lib/girepository-1.0")))
301 `("PATH" ":" prefix
302 (,(string-append (assoc-ref inputs "graphviz") "/bin"))))
303 #t)))))
304 (inputs
305 `(("atk" ,atk)
306 ("gdk-pixbuf" ,gdk-pixbuf+svg)
307 ("graphviz" ,graphviz)
308 ("gtk+" ,gtk+)
309 ("python-pycairo" ,python-pycairo)
310 ("python-pygobject" ,python-pygobject)))
311 (home-page "https://pypi.org/project/xdot/")
312 (synopsis "Interactive viewer for graphviz dot files")
313 (description "Xdot is an interactive viewer for graphs written in
314 @code{graphviz}’s dot language. Internally, it uses the xdot output format as
315 an intermediate format,and @code{gtk} and @code{cairo} for rendering. Xdot can
316 be used either as a standalone application, or as a python library.")
317 (license license:lgpl3+)))
318
319 (define-public python-pydot
320 (package
321 (name "python-pydot")
322 (version "1.2.4")
323 (source
324 (origin
325 (method url-fetch)
326 (uri (pypi-uri "pydot" version))
327 (sha256
328 (base32
329 "1dhy4jpp646jslh2yks6klwwbaxcs905byyny880gl1iap8y5llj"))))
330 (build-system python-build-system)
331 (native-inputs
332 ;; For tests.
333 `(("python-chardet" ,python-chardet)))
334 (propagated-inputs
335 `(("python-pyparsing" ,python-pyparsing)))
336 (home-page "https://github.com/erocarrera/pydot")
337 (synopsis "Python interface to Graphviz's DOT language")
338 (description
339 "Pydot provides an interface to create, handle, modify and process
340 graphs in Graphviz's DOT language, written in pure Python.")
341 (license license:expat)))
342
343 (define-public python2-pydot
344 (package-with-python2 python-pydot))
345
346 (define-public dot2tex
347 (package
348 (name "dot2tex")
349 (version "2.11.3")
350 (source (origin
351 (method url-fetch)
352 (uri (pypi-uri "dot2tex" version))
353 (sha256
354 (base32
355 "1kp77wiv7b5qib82i3y3sn9r49rym43aaqm5aw1bwnzfbbq2m6i9"))))
356 (build-system python-build-system)
357 (arguments
358 `(#:python ,python-2))
359 (inputs
360 `(("texlive-latex-preview" ,texlive-latex-preview)
361 ("graphviz" ,graphviz)))
362 (propagated-inputs
363 `(("python-pyparsing" ,python2-pyparsing)))
364 (home-page "https://github.com/kjellmf/dot2tex")
365 (synopsis "Graphviz to LaTeX converter")
366 (description
367 "The purpose of @code{dot2tex} is to give graphs generated by Graphviz a
368 more LaTeX friendly look and feel. This is accomplished by converting
369 @code{xdot} output from Graphviz to a series of PSTricks or PGF/TikZ commands.
370 This approach allows:
371
372 @itemize @bullet
373 @item Typesetting labels with LaTeX, allowing mathematical notation
374 @item Using native PSTricks and PGF/TikZ commands for drawing arrows
375 @item Using backend specific styles to customize the output
376 @end itemize")
377 (license license:expat)))