graphviz.scm 17 KB

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