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