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