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