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