gnu: xorg-sgml-doctools: Update to 1.12.
[jackhill/guix/guix.git] / gnu / packages / graphviz.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2021 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, 2022 Marius Bakke <marius@gnu.org>
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 ;;; Copyright © 2021 Giacomo Leidi <goodoldpaul@autistici.org>
14 ;;; Copyright © 2021 Justin Veilleux <terramorpha@cock.li>
15 ;;;
16 ;;; This file is part of GNU Guix.
17 ;;;
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
22 ;;;
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
27 ;;;
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30
31 (define-module (gnu packages graphviz)
32 #:use-module (guix packages)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system python)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix utils)
38 #:use-module (guix gexp)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages bison)
42 #:use-module (gnu packages check)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages flex)
45 #:use-module (gnu packages fontutils)
46 #:use-module (gnu packages gd)
47 #:use-module (gnu packages glib)
48 #:use-module (gnu packages gnome)
49 #:use-module (gnu packages gtk)
50 #:use-module (gnu packages guile)
51 #:use-module (gnu packages image)
52 #:use-module (gnu packages perl)
53 #:use-module (gnu packages pkg-config)
54 #:use-module (gnu packages python)
55 #:use-module (gnu packages python-build)
56 #:use-module (gnu packages python-check)
57 #:use-module (gnu packages python-xyz)
58 #:use-module (gnu packages sphinx)
59 #:use-module (gnu packages swig)
60 #:use-module (gnu packages tcl)
61 #:use-module (gnu packages tex)
62 #:use-module (gnu packages xml)
63 #:use-module (gnu packages xorg)
64 #:use-module ((guix licenses) #:prefix license:))
65
66 (define-public graphviz
67 (package
68 (name "graphviz")
69 (version "2.49.0")
70 (source (origin
71 (method url-fetch)
72 (uri (string-append "https://gitlab.com/api/v4/projects/4207231"
73 "/packages/generic/graphviz-releases/"
74 version "/graphviz-" version ".tar.xz"))
75 (sha256
76 (base32
77 "042s6mbi681pwgffqww2ap780230nrsrfpfiz9a41dcjb5a0m524"))))
78 (build-system gnu-build-system)
79 (arguments
80 ;; FIXME: rtest/rtest.sh is a ksh script (!). Add ksh as an input.
81 (list #:tests? #f
82 #:phases
83 #~(modify-phases %standard-phases
84 (add-after 'install 'move-docs
85 (lambda* (#:key outputs #:allow-other-keys)
86 (let ((out (assoc-ref outputs "out"))
87 (doc (assoc-ref outputs "doc")))
88 (mkdir-p (string-append doc "/share/graphviz"))
89 (rename-file (string-append out "/share/graphviz/doc")
90 (string-append doc "/share/graphviz/doc")))))
91 (add-after 'move-docs 'move-guile-bindings
92 (lambda* (#:key outputs #:allow-other-keys)
93 (let* ((out (assoc-ref outputs "out"))
94 (lib (string-append out "/lib"))
95 (extdir (string-append lib "/guile/"
96 #$(version-major+minor
97 (package-version
98 (this-package-input "guile")))
99 "/extensions")))
100 (mkdir-p extdir)
101 (rename-file (string-append
102 lib "/graphviz/guile/libgv_guile.so")
103 (string-append extdir
104 "/libgv_guile.so"))))))))
105 (inputs
106 `(("libXrender" ,libxrender)
107 ("libX11" ,libx11)
108 ("gts" ,gts)
109 ("gd" ,gd)
110 ("guile" ,guile-3.0) ;Guile bindings
111 ("pango" ,pango)
112 ("fontconfig" ,fontconfig)
113 ("freetype" ,freetype)
114 ("libltdl" ,libltdl)
115 ("libXaw" ,libxaw)
116 ("expat" ,expat)
117 ("libjpeg" ,libjpeg-turbo)
118 ("libpng" ,libpng)))
119 (native-inputs
120 (list bison swig pkg-config))
121 (outputs '("out" "doc")) ; 5 MiB of html + pdfs
122 (home-page "https://www.graphviz.org/")
123 (synopsis "Graph visualization software")
124 (description
125 "Graphviz is a graph visualization tool suite. Graph visualization is a
126 way of representing structural information as diagrams of abstract graphs and
127 networks. It has important applications in networking, bioinformatics,
128 software engineering, database and web design, machine learning, and in visual
129 interfaces for other technical domains.")
130 (license license:epl1.0)))
131
132 ;; Older Graphviz needed for pygraphviz. See
133 ;; https://github.com/pygraphviz/pygraphviz/issues/175
134 (define-public graphviz-2.38
135 ;; This commit corresponds to the changelog change for version 2.38.0.
136 ;; There are no tags.
137 (let ((commit "f54ac2c9313ae80ccf76ef4ac6aa9be820a23126")
138 (revision "1"))
139 (package (inherit graphviz)
140 (name "graphviz")
141 (version (git-version "2.38.0" revision commit))
142 (source (origin
143 (method git-fetch)
144 (uri (git-reference
145 (url "https://gitlab.com/graphviz/graphviz.git")
146 (commit commit)))
147 (file-name (git-file-name name version))
148 (sha256
149 (base32
150 "1vjg308gflmi1khgjmcj431cnkrlv12bg4cqah39mwhny92jy92x"))))
151 (arguments
152 (substitute-keyword-arguments (package-arguments graphviz)
153 ((#:phases phases)
154 #~(modify-phases #$phases
155 (add-after 'unpack 'prepare-bootstrap
156 (lambda _
157 (substitute* "autogen.sh"
158 (("/bin/sh") (which "sh"))
159 (("\\$GRAPHVIZ_VERSION_DATE") "0"))
160 (setenv "CONFIG_SHELL" (which "sh"))
161 (setenv "SHELL" (which "sh"))
162
163 (map make-file-writable (find-files "." ".*"))
164 #t))
165 (replace 'bootstrap
166 (lambda _
167 (invoke (which "sh") "autogen.sh" "NOCONFIG") #t))))))
168 (native-inputs
169 (modify-inputs (package-native-inputs graphviz)
170 (prepend autoconf
171 automake
172 libtool
173 flex
174 perl
175 tcl))))))
176
177 (define-public python-graphviz
178 (package
179 (name "python-graphviz")
180 (version "0.13.2")
181 (source (origin
182 (method url-fetch)
183 (uri (pypi-uri "graphviz" version ".zip"))
184 (sha256
185 (base32
186 "009alrilzx0v7kl41khbq7k6k8b8pxyvbsi1b1ai933f6kpbxb30"))))
187 (build-system python-build-system)
188 (arguments
189 '(#:phases (modify-phases %standard-phases
190 (replace 'check
191 (lambda* (#:key tests #:allow-other-keys)
192 (if tests
193 (invoke "pytest" "-vv")
194 (format #t "test suite not run~%"))
195 #t)))))
196 (native-inputs
197 (list unzip
198 ;; For tests.
199 graphviz
200 python-mock
201 python-pytest
202 python-pytest-cov
203 python-pytest-mock))
204 (home-page "https://github.com/xflr6/graphviz")
205 (synopsis "Simple Python interface for Graphviz")
206 (description
207 "This package provides a simple Python interface for the Graphviz graph
208 visualization tool suite.")
209 (license license:expat)))
210
211 (define-public python-pygraphviz
212 (package
213 (name "python-pygraphviz")
214 (version "1.7")
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 "0jqc3dzy9n0hn3b99zq8jp53901zpjzvvi5ns5mbaxg8kdrb1lfx"))))
225 (build-system python-build-system)
226 (inputs
227 (list graphviz))
228 (native-inputs
229 (list python-nose python-mock python-pytest
230 python-doctest-ignore-unicode))
231 (home-page "https://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 python-uqbar
240 (package
241 (name "python-uqbar")
242 (version "0.5.6")
243 (source
244 (origin
245 (method git-fetch)
246 (uri (git-reference
247 (url "https://github.com/josiah-wolf-oberholtzer/uqbar")
248 (commit (string-append "v" version))))
249 (file-name (git-file-name name version))
250 (sha256
251 (base32
252 "1ml3x2mf7nlnvrh9lari5yk0sz2mmg39jwsbjxnpzhnw4kcwpdrs"))))
253 (build-system python-build-system)
254 (arguments
255 `(#:phases
256 (modify-phases %standard-phases
257 (add-after 'unpack 'patch
258 (lambda _
259 (substitute* "setup.py"
260 ;; Latest versions of sphink-rtd-theme require npm to build.
261 (("sphinx-rtd-theme >= 0.5.0") "sphinx-rtd-theme >= 0.2.4")
262 (("black") "black >= 19.10b0"))
263 #t))
264 (replace 'check
265 (lambda* (#:key tests? #:allow-other-keys)
266 (when tests?
267 (invoke "python" "-m" "pytest" "tests"))
268 #t)))))
269 (native-inputs
270 (list graphviz
271 python-flake8
272 python-isort
273 python-mypy
274 python-pytest
275 python-pytest-cov))
276 (propagated-inputs
277 (list python-black python-sphinx python-sphinx-rtd-theme
278 python-unidecode))
279 (home-page "https://github.com/josiah-wolf-oberholtzer/uqbar")
280 (synopsis "Tools for building documentation with Sphinx, Graphviz and LaTeX")
281 (description
282 "This package contains tools for building documentation with Sphinx,
283 Graphviz and LaTeX.")
284 (license license:expat)))
285
286 (define-public gts
287 (package
288 (name "gts")
289 (version "0.7.6")
290 (source (origin
291 (method url-fetch)
292 (uri (string-append "mirror://sourceforge/gts/gts/" version
293 "/gts-" version ".tar.gz"))
294 (sha256
295 (base32
296 "07mqx09jxh8cv9753y2d2jsv7wp8vjmrd7zcfpbrddz3wc9kx705"))))
297 (build-system gnu-build-system)
298 (arguments
299 '(#:phases
300 (modify-phases %standard-phases
301 (add-before 'check 'pre-check
302 (lambda _
303 (chmod "test/boolean/test.sh" #o777)
304 #t)))
305
306 ;; Some data files used by the test suite are missing.
307 ;; See <http://sourceforge.net/p/gts/bugs/41/>.
308 #:tests? #f))
309 (native-inputs
310 (list pkg-config))
311 (propagated-inputs
312 ;; The gts.pc file has glib-2.0 as required.
313 (list glib))
314 (home-page "http://gts.sourceforge.net/")
315
316 ;; Note: Despite the name, this is not official GNU software.
317 (synopsis "Triangulated Surface Library")
318 (description
319 "Library intended to provide a set of useful functions to deal with
320 3D surfaces meshed with interconnected triangles.")
321 (license license:lgpl2.0+)))
322
323 (define-public xdot
324 (package
325 (name "xdot")
326 (version "1.1")
327 (source
328 (origin
329 (method url-fetch)
330 (uri (pypi-uri "xdot" version))
331 (sha256
332 (base32
333 "0cr4rh7dz4dfzyxrk5pzhm0d15gkrgkfp3i5lw178xy81pc56p71"))))
334 (build-system python-build-system)
335 (arguments
336 `(#:phases
337 (modify-phases %standard-phases
338 ;; We wrap xdot, so that we don't propagate gtk+ and graphviz
339 (add-after 'install 'wrap
340 (lambda* (#:key inputs outputs #:allow-other-keys)
341 (wrap-program (string-append (assoc-ref outputs "out") "/bin/xdot")
342 `("GI_TYPELIB_PATH" ":" prefix
343 (,(string-append
344 (assoc-ref inputs "gtk+") "/lib/girepository-1.0"
345 ":" (assoc-ref inputs "pango") "/lib/girepository-1.0"
346 ":" (assoc-ref inputs "gdk-pixbuf") "/lib/girepository-1.0"
347 ":" (assoc-ref inputs "atk") "/lib/girepository-1.0"
348 ":" (assoc-ref inputs "harfbuzz") "/lib/girepository-1.0")))
349 `("PATH" ":" prefix
350 (,(dirname (search-input-file inputs "bin/dot"))))))))))
351 (inputs
352 (list atk
353 librsvg
354 harfbuzz
355 graphviz
356 gtk+
357 python-pycairo
358 python-pygobject))
359 (home-page "https://pypi.org/project/xdot/")
360 (synopsis "Interactive viewer for graphviz dot files")
361 (description "Xdot is an interactive viewer for graphs written in
362 @code{graphviz}’s dot language. Internally, it uses the xdot output format as
363 an intermediate format, and @code{gtk} and @code{cairo} for rendering. Xdot
364 can be used either as a standalone application, or as a Python library.")
365 (license license:lgpl3+)))
366
367 (define-public python-pydot
368 (package
369 (name "python-pydot")
370 (version "1.4.2")
371 (source
372 (origin
373 (method url-fetch)
374 (uri (pypi-uri "pydot" version))
375 (sha256
376 (base32
377 "0z80zwldf7ffkwrpm28hixsiqp3053j7g281xd6phmnbkfiq3014"))))
378 (build-system python-build-system)
379 (arguments
380 '(#:phases
381 (modify-phases %standard-phases
382 (replace 'check
383 ;; Taken from .travis.yaml
384 (lambda* (#:key tests? inputs outputs #:allow-other-keys)
385 (when tests?
386 (add-installed-pythonpath inputs outputs)
387 (with-directory-excursion "test"
388 (invoke "python" "pydot_unittest.py"))))))))
389 (native-inputs
390 ;; For tests.
391 (list graphviz python-chardet))
392 (propagated-inputs
393 ;; XXX: Two test failures with 3.0+:
394 ;; https://github.com/pydot/pydot/issues/277
395 (list python-pyparsing-2.4.7))
396 (home-page "https://github.com/pydot/pydot")
397 (synopsis "Python interface to Graphviz's DOT language")
398 (description
399 "Pydot provides an interface to create, handle, modify and process
400 graphs in Graphviz's DOT language, written in pure Python.")
401 (license license:expat)))
402
403 (define-public dot2tex
404 (package
405 (name "dot2tex")
406 (version "2.11.3")
407 (source (origin
408 (method url-fetch)
409 (uri (pypi-uri "dot2tex" version))
410 (sha256
411 (base32
412 "1kp77wiv7b5qib82i3y3sn9r49rym43aaqm5aw1bwnzfbbq2m6i9"))))
413 (build-system python-build-system)
414 (arguments
415 (list
416 #:phases
417 #~(modify-phases %standard-phases
418 (replace 'check
419 (lambda* (#:key tests? #:allow-other-keys)
420 (when tests?
421 (invoke "pytest" "-vv" "tests"
422 ;; The test_semicolon test fails for unknown reason
423 ;; (see:
424 ;; https://github.com/kjellmf/dot2tex/issues/94).
425 "-k" "not test_semicolon")))))))
426 (native-inputs (list python-pytest))
427 (inputs (list graphviz))
428 (propagated-inputs
429 (list python-pyparsing
430 ;; These TeX dependencies are propagated to make it easier to build
431 ;; the resulting generated TeX files, which \usepackage them.
432 texlive-bin
433 texlive-amsmath
434 texlive-latex-geometry
435 texlive-latex-graphics
436 texlive-latex-base
437 texlive-latex-preview
438 texlive-latex-xkeyval
439 texlive-pgf
440 texlive-pstricks
441 texlive-xcolor))
442 (home-page "https://github.com/kjellmf/dot2tex")
443 (synopsis "Graphviz to LaTeX converter")
444 (description
445 "The purpose of @code{dot2tex} is to give graphs generated by Graphviz a
446 more LaTeX friendly look and feel. This is accomplished by converting
447 @code{xdot} output from Graphviz to a series of PSTricks or PGF/TikZ commands.
448 This approach allows:
449
450 @itemize @bullet
451 @item Typesetting labels with LaTeX, allowing mathematical notation
452 @item Using native PSTricks and PGF/TikZ commands for drawing arrows
453 @item Using backend specific styles to customize the output
454 @end itemize")
455 (license license:expat)))
456
457 (define-public gprof2dot
458 (package
459 (name "gprof2dot")
460 (version "2021.02.21")
461 (source
462 (origin
463 (method git-fetch)
464 (uri (git-reference
465 (url "https://github.com/jrfonseca/gprof2dot")
466 (commit version)))
467 (file-name (git-file-name name version))
468 (sha256
469 (base32
470 "1jjhsjf5fdi1fkn7mvhnzkh6cynl8gcjrygd3cya5mmda3akhzic"))))
471 (build-system python-build-system)
472 (arguments
473 `(#:phases
474 (modify-phases %standard-phases
475 (replace 'check
476 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
477 (when tests?
478 (add-installed-pythonpath inputs outputs)
479 (invoke "python" "tests/test.py")))))))
480 (native-inputs
481 (list graphviz))
482 (home-page "https://github.com/jrfonseca/gprof2dot")
483 (synopsis "Generate a dot graph from the output of several profilers")
484 (description "This package provides a Python script to convert the output
485 from many profilers into a dot graph.
486
487 It can:
488
489 @itemize
490
491 @item prune nodes and edges below a certain threshold;
492 @item use an heuristic to propagate time inside mutually recursive functions;
493 @item use color efficiently to draw attention to hot-spots;
494 @item work on any platform where Python and Graphviz is available.
495
496 @end itemize")
497 (license license:lgpl3+)))