plotutils.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
  4. ;;; Copyright © 2016, 2017, 2019, 2020, 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
  5. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages plotutils)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module (guix packages)
  25. #:use-module (guix download)
  26. #:use-module (guix git-download)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (gnu packages algebra)
  29. #:use-module (gnu packages autotools)
  30. #:use-module (gnu packages bdw-gc)
  31. #:use-module (gnu packages emacs)
  32. #:use-module (gnu packages xorg)
  33. #:use-module (gnu packages image)
  34. #:use-module (gnu packages ghostscript)
  35. #:use-module (gnu packages guile)
  36. #:use-module (gnu packages gl)
  37. #:use-module (gnu packages gtk)
  38. #:use-module (gnu packages maths)
  39. #:use-module (gnu packages perl)
  40. #:use-module (gnu packages pkg-config)
  41. #:use-module (gnu packages python)
  42. #:use-module (gnu packages python-xyz)
  43. #:use-module (gnu packages readline)
  44. #:use-module (gnu packages qt)
  45. #:use-module (gnu packages texinfo)
  46. #:use-module (gnu packages tex)
  47. #:use-module (gnu packages compression)
  48. #:use-module (gnu packages))
  49. (define-public plotutils
  50. (package
  51. (name "plotutils")
  52. (version "2.6")
  53. (source (origin
  54. (method url-fetch)
  55. (uri (string-append "mirror://gnu/plotutils/plotutils-"
  56. version ".tar.gz"))
  57. (sha256
  58. (base32
  59. "1arkyizn5wbgvbh53aziv3s6lmd3wm9lqzkhxb3hijlp1y124hjg"))
  60. (modules '((guix build utils)))
  61. (snippet
  62. ;; Force the use of libXaw7 instead of libXaw. When not doing
  63. ;; that, libplot.la ends up containing just "-lXaw" (without
  64. ;; "-L/path/to/Xaw"), due to the fact that there is no
  65. ;; libXaw.la, which forces us to propagate libXaw.
  66. '(begin
  67. (substitute* "configure"
  68. (("-lXaw")
  69. "-lXaw7"))
  70. ;; Use the `png_jmpbuf' accessor, as recommended since libpng
  71. ;; 1.4.0 (see:
  72. ;; http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt).
  73. (substitute* "libplot/z_write.c"
  74. (("png_ptr->jmpbuf")
  75. "png_jmpbuf (png_ptr)"))
  76. #t))
  77. (patches
  78. ;; The test suite fails on some architectures such as i686 (see:
  79. ;; https://lists.gnu.org/archive/html/bug-plotutils/2016-04/msg00002.html).
  80. ;; The following Debian patch works around it.
  81. (search-patches "plotutils-spline-test.patch"))))
  82. (build-system gnu-build-system)
  83. (arguments
  84. `(#:configure-flags (list "--enable-libplotter")))
  85. (inputs `(("libpng" ,libpng)
  86. ("libx11" ,libx11)
  87. ("libxt" ,libxt)
  88. ("libxaw" ,libxaw)))
  89. (home-page "https://www.gnu.org/software/plotutils/")
  90. (synopsis "Plotting utilities and library")
  91. (description
  92. "GNU Plotutils is a package for plotting and working with 2D graphics.
  93. It includes the C library @code{libplot} and the C++ @code{libplotter} library
  94. for exporting 2D vector graphics in many file formats. It also has support
  95. for 2D vector graphics animations. The package also contains command-line
  96. programs for plotting scientific data.")
  97. (license license:gpl2+)))
  98. (define-public guile-charting
  99. ;; This commit fixes a few things, including Guile 3 support, not available
  100. ;; in the latest release.
  101. (let ((commit "75f755b691a9f712f3b956657d01805d6a8a1b98")
  102. (revision "1"))
  103. (package
  104. (name "guile-charting")
  105. (version (git-version "0.2.0" revision commit))
  106. (source (origin
  107. (method git-fetch)
  108. (uri (git-reference
  109. (url "https://gitlab.com/wingo/guile-charting")
  110. (commit commit)))
  111. (file-name (git-file-name name version))
  112. (sha256
  113. (base32
  114. "03049g7wnpyfi0r36ij4a46kc9l45jbanx02iklkjwav2n6jqnnk"))))
  115. (build-system gnu-build-system)
  116. (native-inputs
  117. `(("autoconf" ,autoconf)
  118. ("automake" ,automake)
  119. ("texinfo" ,texinfo)
  120. ("pkg-config" ,pkg-config)))
  121. (inputs `(("guile" ,guile-3.0)))
  122. (propagated-inputs `(("guile-cairo" ,guile-cairo)))
  123. (home-page "http://wingolog.org/projects/guile-charting/")
  124. (synopsis "Create charts and graphs in Guile")
  125. (description
  126. "Guile-Charting is a Guile Scheme library to create bar charts and graphs
  127. using the Cairo drawing library.")
  128. (license license:lgpl2.1+))))
  129. (define-public guile2.2-charting
  130. (package
  131. (inherit guile-charting)
  132. (name "guile2.2-charting")
  133. (inputs `(("guile" ,guile-2.2)))
  134. (propagated-inputs `(("guile-cairo" ,guile2.2-cairo)))))
  135. (define-public guile3.0-charting
  136. (deprecated-package "guile3.0-charting" guile-charting))
  137. (define-public ploticus
  138. (package
  139. (name "ploticus")
  140. (version "2.42")
  141. (source (origin
  142. (method url-fetch)
  143. (uri (string-append "mirror://sourceforge/ploticus/ploticus/"
  144. version "/ploticus242_src.tar.gz"))
  145. (sha256
  146. (base32
  147. "1c70cvfvgjh83hj1x21130wb9qfr2rc0x47cxy9kl805yjwy8a9z"))
  148. (modules '((guix build utils)))
  149. (snippet
  150. ;; Install binaries in the right place.
  151. '(begin
  152. (substitute* "src/Makefile"
  153. (("INSTALLBIN =.*$")
  154. (string-append "INSTALLBIN = $(out)/bin")))
  155. #t))))
  156. (build-system gnu-build-system)
  157. (arguments
  158. '(#:tests? #f
  159. #:phases
  160. (modify-phases %standard-phases
  161. (replace 'configure (lambda _ (chdir "src")))
  162. (add-before 'install 'make-target-directories
  163. (lambda* (#:key outputs #:allow-other-keys)
  164. (let ((out (assoc-ref outputs "out")))
  165. (mkdir-p (string-append out "/bin"))
  166. #t)))
  167. (add-after 'install 'install-prefabs
  168. (lambda* (#:key outputs #:allow-other-keys)
  169. (let* ((out (assoc-ref outputs "out"))
  170. (dir (string-append out
  171. "/share/ploticus/prefabs"))
  172. (bin (string-append out "/bin")))
  173. (mkdir-p dir)
  174. ;; Install "prefabs".
  175. (for-each (lambda (file)
  176. (let ((target
  177. (string-append dir "/"
  178. (basename file))))
  179. (copy-file file target)))
  180. (find-files "../prefabs" "."))
  181. ;; Allow them to be found.
  182. (wrap-program (string-append bin "/pl")
  183. `("PLOTICUS_PREFABS" ":" = (,dir)))))))))
  184. (inputs
  185. `(("libpng" ,libpng)
  186. ("libx11" ,libx11)
  187. ("zlib" ,zlib)))
  188. (home-page "http://ploticus.sourceforge.net/")
  189. (synopsis "Command-line tool for producing plots and charts")
  190. (description
  191. "Ploticus is a non-interactive software package for producing plots,
  192. charts, and graphics from data. Ploticus is good for automated or
  193. just-in-time graph generation, handles date and time data nicely, and has
  194. basic statistical capabilities. It allows significant user control over
  195. colors, styles, options and details.")
  196. (license license:gpl2+)))
  197. (define-public asymptote
  198. (package
  199. (name "asymptote")
  200. (version "2.70")
  201. (source
  202. (origin
  203. (method url-fetch)
  204. (uri (string-append "mirror://sourceforge/asymptote/"
  205. version "/asymptote-" version ".src.tgz"))
  206. (sha256
  207. (base32 "0gqcm0m916kjzyfswlplhyyvmqhg9hsishmbg4pyjcwchlx93k7m"))))
  208. (build-system gnu-build-system)
  209. ;; Note: The 'asy' binary retains a reference to docdir for use with its
  210. ;; "help" command in interactive mode, so adding a "doc" output is not
  211. ;; currently useful.
  212. (native-inputs
  213. `(("emacs" ,emacs-minimal)
  214. ("gs" ,ghostscript) ;For tests
  215. ("perl" ,perl)
  216. ("texinfo" ,texinfo) ;For generating documentation
  217. ;; For the manual and the tests.
  218. ("texlive" ,(texlive-updmap.cfg (list texlive-amsfonts
  219. texlive-epsf
  220. texlive-etoolbox
  221. texlive-latex-base
  222. texlive-latex-geometry
  223. texlive-latex-graphics
  224. texlive-oberdiek ;for ifluatex
  225. texlive-latex-parskip
  226. texlive-tex-texinfo)))))
  227. (inputs
  228. `(("fftw" ,fftw)
  229. ("freeglut" ,freeglut)
  230. ("glew" ,glew)
  231. ("glm" ,glm)
  232. ("gsl" ,gsl)
  233. ("libgc" ,libgc)
  234. ("python" ,python)
  235. ("python-cson" ,python-cson)
  236. ("python-numpy" ,python-numpy)
  237. ("python-pyqt" ,python-pyqt)
  238. ("readline" ,readline)
  239. ("zlib" ,zlib)))
  240. (arguments
  241. `(#:modules ((guix build emacs-utils)
  242. (guix build gnu-build-system)
  243. (guix build utils)
  244. (srfi srfi-26))
  245. #:imported-modules (,@%gnu-build-system-modules
  246. (guix build emacs-utils))
  247. #:configure-flags
  248. (list (string-append "--enable-gc=" (assoc-ref %build-inputs "libgc"))
  249. (string-append "--with-latex="
  250. (assoc-ref %outputs "out")
  251. "/share/texmf/tex/latex")
  252. (string-append "--with-context="
  253. (assoc-ref %outputs "out")
  254. "/share/texmf/tex/context/third"))
  255. #:phases
  256. (modify-phases %standard-phases
  257. (add-after 'unpack 'fix-build
  258. ;; XXX: Build process complains about missing "config.h"
  259. ;; and "primitives.h" files.
  260. (lambda _
  261. (substitute* (find-files "." "\\.in$")
  262. (("#include <primitives.h>") "#include \"primitives.h\""))
  263. (invoke "touch" "prc/config.h")))
  264. (add-after 'unpack 'move-info-location
  265. ;; Build process installs info file in the unusual
  266. ;; "%out/share/info/asymptote/" location. Move it to
  267. ;; "%out/share/info/" so it appears in the top-level directory.
  268. (lambda _
  269. (substitute* "doc/png/Makefile.in"
  270. (("(\\$\\(infodir\\))/asymptote" _ infodir) infodir))
  271. (substitute* "doc/asymptote.texi"
  272. (("asymptote/asymptote") "asymptote"))
  273. #t))
  274. (add-before 'build 'patch-pdf-viewer
  275. (lambda _
  276. ;; Default to a free pdf viewer.
  277. (substitute* "settings.cc"
  278. (("defaultPDFViewer=\"acroread\"")
  279. "defaultPDFViewer=\"gv\""))
  280. #t))
  281. (add-before 'check 'set-HOME
  282. ;; Some tests require write access to $HOME, otherwise leading to
  283. ;; "failed to create directory /homeless-shelter/.asy" error.
  284. (lambda _
  285. (setenv "HOME" "/tmp")
  286. #t))
  287. (add-after 'install 'install-Emacs-data
  288. (lambda* (#:key outputs #:allow-other-keys)
  289. ;; Install related Emacs libraries into an appropriate location.
  290. (let* ((out (assoc-ref outputs "out"))
  291. (lisp-dir (string-append out "/share/emacs/site-lisp")))
  292. (for-each (cut install-file <> lisp-dir)
  293. (find-files "." "\\.el$"))
  294. (emacs-generate-autoloads ,name lisp-dir))
  295. #t))
  296. (add-after 'install-Emacs-data 'wrap-python-script
  297. (lambda* (#:key inputs outputs #:allow-other-keys)
  298. ;; Make sure 'xasy' runs with the correct PYTHONPATH.
  299. (let* ((out (assoc-ref outputs "out"))
  300. (path (getenv "GUIX_PYTHONPATH")))
  301. (wrap-program (string-append out "/share/asymptote/GUI/xasy.py")
  302. `("GUIX_PYTHONPATH" ":" prefix (,path))))
  303. #t)))))
  304. (home-page "http://asymptote.sourceforge.net")
  305. (synopsis "Script-based vector graphics language")
  306. (description
  307. "Asymptote is a powerful descriptive vector graphics language for
  308. technical drawing, inspired by MetaPost but with an improved C++-like syntax.
  309. Asymptote provides for figures the same high-quality level of typesetting that
  310. LaTeX does for scientific text.")
  311. ;; Most source files do not contain license statements, but the README
  312. ;; contains: "All source files in the Asymptote project, unless explicitly
  313. ;; noted otherwise, are released under version 3 (or later) of the GNU
  314. ;; Lesser General Public License"
  315. (license license:lgpl3+)))