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