gnu: qtwebengine: Rename to qtwebengine-5.
[jackhill/guix/guix.git] / gnu / packages / plotutils.scm
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-2022 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
23 (define-module (gnu packages plotutils)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix gexp)
26 #:use-module ((guix utils) #:select (target-x86-32?))
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages bdw-gc)
34 #:use-module (gnu packages boost)
35 #:use-module (gnu packages cmake)
36 #:use-module (gnu packages emacs)
37 #:use-module (gnu packages xorg)
38 #:use-module (gnu packages image)
39 #:use-module (gnu packages ghostscript)
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages gl)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages maths)
44 #:use-module (gnu packages onc-rpc)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages readline)
50 #:use-module (gnu packages qt)
51 #:use-module (gnu packages texinfo)
52 #:use-module (gnu packages tex)
53 #:use-module (gnu packages web)
54 #:use-module (gnu packages compression)
55 #:use-module (gnu packages))
56
57 (define-public plotutils
58 (package
59 (name "plotutils")
60 (version "2.6")
61 (source (origin
62 (method url-fetch)
63 (uri (string-append "mirror://gnu/plotutils/plotutils-"
64 version ".tar.gz"))
65 (sha256
66 (base32
67 "1arkyizn5wbgvbh53aziv3s6lmd3wm9lqzkhxb3hijlp1y124hjg"))
68 (modules '((guix build utils)))
69 (snippet
70 ;; Force the use of libXaw7 instead of libXaw. When not doing
71 ;; that, libplot.la ends up containing just "-lXaw" (without
72 ;; "-L/path/to/Xaw"), due to the fact that there is no
73 ;; libXaw.la, which forces us to propagate libXaw.
74 '(begin
75 (substitute* "configure"
76 (("-lXaw")
77 "-lXaw7"))
78 ;; Use the `png_jmpbuf' accessor, as recommended since libpng
79 ;; 1.4.0 (see:
80 ;; http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt).
81 (substitute* "libplot/z_write.c"
82 (("png_ptr->jmpbuf")
83 "png_jmpbuf (png_ptr)"))
84 #t))
85 (patches
86 ;; The test suite fails on some architectures such as i686 (see:
87 ;; https://lists.gnu.org/archive/html/bug-plotutils/2016-04/msg00002.html).
88 ;; The following Debian patch works around it.
89 (search-patches "plotutils-spline-test.patch"))))
90 (build-system gnu-build-system)
91 (arguments
92 (list #:configure-flags
93 #~(list "--enable-libplotter"
94
95 ;; On i686 some tests fail due to excess floating point
96 ;; precision; work around it. However, libplotter is C++
97 ;; and thus unaffected by CFLAGS, but '-fexcess-precision'
98 ;; is not implemented for C++ as of GCC 10.
99 #$@(if (target-x86-32?)
100 #~("CFLAGS=-g -O2 -fexcess-precision=standard")
101 #~()))
102
103 #:phases
104 (if (target-x86-32?)
105 #~(modify-phases %standard-phases
106 (add-before 'check 'skip-sloppy-test
107 (lambda _
108 ;; This test reveals a slight difference in the SVG
109 ;; output due to floating point inequalities. Skip it.
110 (substitute* "test/plot2svg.test"
111 (("^exit .*") "exit 77")))))
112 #~%standard-phases)))
113 (inputs (list libpng libx11 libxt libxaw))
114 (home-page "https://www.gnu.org/software/plotutils/")
115 (synopsis "Plotting utilities and library")
116 (description
117 "GNU Plotutils is a package for plotting and working with 2D graphics.
118 It includes the C library @code{libplot} and the C++ @code{libplotter} library
119 for exporting 2D vector graphics in many file formats. It also has support
120 for 2D vector graphics animations. The package also contains command-line
121 programs for plotting scientific data.")
122 (license license:gpl2+)))
123
124 (define-public guile-plotutils
125 (package
126 (name "guile-plotutils")
127 (version "1.0.1")
128 (source (origin
129 (method url-fetch)
130 (uri (list (string-append "https://lonelycactus.com/tarball/"
131 "guile_plotutils-" version ".tar.gz")
132 (string-append
133 "https://github.com/spk121/guile-plotutils/releases/download/v"
134 version "/guile_plotutils-" version
135 ".tar.gz")))
136 (sha256
137 (base32
138 "0r245z75cdzgzi57fpz84mnyrjq44793zzaaxxrszyxm1d06hc6r"))))
139 (build-system gnu-build-system)
140 (arguments
141 `(#:imported-modules ((guix build guile-build-system)
142 ,@%gnu-build-system-modules)
143 #:modules (((guix build guile-build-system)
144 #:select (target-guile-effective-version))
145 (guix build gnu-build-system)
146 (guix build utils))
147 #:phases
148 (modify-phases %standard-phases
149 (add-before 'install 'set-library-file-name
150 (lambda* (#:key outputs #:allow-other-keys)
151 (let ((out (assoc-ref outputs "out"))
152 (version (target-guile-effective-version)))
153 ;; First install libguile-plotutils.so.
154 (invoke "make" "install-guileextensionLTLIBRARIES")
155
156 ;; Then change source files to refer to it.
157 (substitute* '("module/plotutils/graph.scm"
158 "module/plotutils/plot.scm")
159 (("\"libguile-plotutils\"")
160 (string-append "\"" out "/lib/guile/" version
161 "/extensions/libguile-plotutils\"")))))))))
162 (native-inputs (list pkg-config texinfo))
163 (inputs (list plotutils guile-3.0 zlib))
164 (home-page "https://lonelycactus.com/guile-plotutils.html")
165 (synopsis "Guile bindings to the GNU Plotutils plotting libraries")
166 (description
167 "Guile-Plotutils is a Guile binding to the venerable GNU Plotutils
168 plotting and graphing library. If you want to make graphs that look like you
169 went to university in the 1990s, this is the library for you.")
170 (license license:gpl3+)))
171
172 (define-public guile-charting
173 ;; This commit fixes a few things, including Guile 3 support, not available
174 ;; in the latest release.
175 (let ((commit "75f755b691a9f712f3b956657d01805d6a8a1b98")
176 (revision "1"))
177 (package
178 (name "guile-charting")
179 (version (git-version "0.2.0" revision commit))
180 (source (origin
181 (method git-fetch)
182 (uri (git-reference
183 (url "https://gitlab.com/wingo/guile-charting")
184 (commit commit)))
185 (file-name (git-file-name name version))
186 (sha256
187 (base32
188 "03049g7wnpyfi0r36ij4a46kc9l45jbanx02iklkjwav2n6jqnnk"))))
189 (build-system gnu-build-system)
190 (native-inputs
191 (list autoconf automake texinfo pkg-config))
192 (inputs (list guile-3.0))
193 (propagated-inputs (list guile-cairo))
194 (home-page "http://wingolog.org/projects/guile-charting/")
195 (synopsis "Create charts and graphs in Guile")
196 (description
197 "Guile-Charting is a Guile Scheme library to create bar charts and graphs
198 using the Cairo drawing library.")
199 (license license:lgpl2.1+))))
200
201 (define-public guile2.2-charting
202 (package
203 (inherit guile-charting)
204 (name "guile2.2-charting")
205 (inputs (list guile-2.2))
206 (propagated-inputs (list guile2.2-cairo))))
207
208 (define-public ploticus
209 (package
210 (name "ploticus")
211 (version "2.42")
212 (source (origin
213 (method url-fetch)
214 (uri (string-append "mirror://sourceforge/ploticus/ploticus/"
215 version "/ploticus242_src.tar.gz"))
216 (sha256
217 (base32
218 "1c70cvfvgjh83hj1x21130wb9qfr2rc0x47cxy9kl805yjwy8a9z"))
219 (modules '((guix build utils)))
220 (snippet
221 ;; Install binaries in the right place.
222 '(begin
223 (substitute* "src/Makefile"
224 (("INSTALLBIN =.*$")
225 (string-append "INSTALLBIN = $(out)/bin")))
226 #t))))
227 (build-system gnu-build-system)
228 (arguments
229 '(#:tests? #f
230 #:phases
231 (modify-phases %standard-phases
232 (replace 'configure (lambda _ (chdir "src")))
233 (add-before 'install 'make-target-directories
234 (lambda* (#:key outputs #:allow-other-keys)
235 (let ((out (assoc-ref outputs "out")))
236 (mkdir-p (string-append out "/bin"))
237 #t)))
238 (add-after 'install 'install-prefabs
239 (lambda* (#:key outputs #:allow-other-keys)
240 (let* ((out (assoc-ref outputs "out"))
241 (dir (string-append out
242 "/share/ploticus/prefabs"))
243 (bin (string-append out "/bin")))
244 (mkdir-p dir)
245
246 ;; Install "prefabs".
247 (for-each (lambda (file)
248 (let ((target
249 (string-append dir "/"
250 (basename file))))
251 (copy-file file target)))
252 (find-files "../prefabs" "."))
253
254 ;; Allow them to be found.
255 (wrap-program (string-append bin "/pl")
256 `("PLOTICUS_PREFABS" ":" = (,dir)))))))))
257 (inputs
258 (list libpng libx11 zlib))
259 (home-page "http://ploticus.sourceforge.net/")
260 (synopsis "Command-line tool for producing plots and charts")
261 (description
262 "Ploticus is a non-interactive software package for producing plots,
263 charts, and graphics from data. Ploticus is good for automated or
264 just-in-time graph generation, handles date and time data nicely, and has
265 basic statistical capabilities. It allows significant user control over
266 colors, styles, options and details.")
267 (license license:gpl2+)))
268
269 (define-public asymptote
270 (package
271 (name "asymptote")
272 (version "2.81")
273 (source
274 (origin
275 (method url-fetch)
276 (uri (string-append "mirror://sourceforge/asymptote/"
277 version "/asymptote-" version ".src.tgz"))
278 (sha256
279 (base32 "0wq0xnkxb8rsphmgls5f38ll61j8i0plh7cr1n0kldvpr14bm3kn"))
280 (modules '((guix build utils)))
281 (snippet
282 ;; Remove bundled RapidJSON.
283 #~(begin
284 (delete-file-recursively "LspCpp/third_party/rapidjson")))))
285 (build-system gnu-build-system)
286 ;; Note: The 'asy' binary retains a reference to docdir for use with its
287 ;; "help" command in interactive mode, so adding a "doc" output is not
288 ;; currently useful.
289 (native-inputs
290 (list autoconf
291 automake
292 boost
293 cmake
294 emacs-minimal
295 ghostscript ;for tests
296 perl
297 rapidjson
298 texinfo ;for generating documentation
299 (texlive-updmap.cfg
300 (list texlive-amsfonts
301 texlive-dvips-l3backend
302 texlive-epsf
303 texlive-etoolbox
304 texlive-fonts-ec
305 texlive-generic-infwarerr
306 texlive-generic-kvdefinekeys
307 texlive-grfext
308 texlive-hyperref
309 texlive-latex-base
310 texlive-latex-geometry
311 texlive-latex-graphics
312 texlive-latex-kvoptions
313 texlive-latex-media9
314 texlive-latex-ocgx2
315 texlive-latex-pdftexcmds
316 texlive-oberdiek ;for ifluatex
317 texlive-latex-parskip
318 texlive-tex-texinfo))))
319 (inputs
320 (list fftw
321 freeglut
322 glew
323 glm
324 gsl
325 libgc
326 libtirpc
327 python
328 python-cson
329 python-numpy
330 python-pyqt
331 readline
332 zlib))
333 (arguments
334 (list
335 #:modules '((guix build emacs-utils)
336 (guix build gnu-build-system)
337 (guix build utils)
338 (srfi srfi-26))
339 #:imported-modules `(,@%gnu-build-system-modules
340 (guix build emacs-utils))
341 #:configure-flags
342 #~(list (string-append "--enable-gc=" #$(this-package-input "libgc"))
343 (string-append "--with-latex=" #$output "/share/texmf/tex/latex")
344 (string-append "--with-context="
345 #$output
346 "/share/texmf/tex/context/third"))
347 #:phases
348 #~(modify-phases %standard-phases
349 (add-after 'unpack 'locate-tirpc
350 (lambda* (#:key inputs #:allow-other-keys)
351 (substitute* (list "configure.ac")
352 (("/usr/include/tirpc")
353 (search-input-directory inputs "include/tirpc")))))
354 (add-after 'unpack 'unbundle-rapidjson
355 (lambda* (#:key inputs #:allow-other-keys)
356 (substitute* (list "Makefile.in")
357 (("\\$\\(CMAKE\\)" all)
358 (string-append all " -DUSE_SYSTEM_RAPIDJSON=ON")))))
359 (add-after 'unpack 'fix-includes
360 (lambda _
361 (substitute* (find-files "." "\\.in$")
362 (("#include <primitives.h>") "#include \"primitives.h\""))
363 (substitute* (find-files "prc" "\\.h$")
364 (("#include \"config.h\"") "#include \"../config.h\""))
365 (substitute* "prc/oPRCFile.h"
366 (("#include \"xstream.h\"") "#include \"../xstream.h\""))
367 (substitute* "v3dfile.h"
368 (("#include <prc/oPRCFile.h>") "#include \"prc/oPRCFile.h\""))
369 (substitute* "LspCpp/src/lsp/ParentProcessWatcher.cpp"
370 (("#include <boost/process.hpp>" all)
371 (string-append "#include <algorithm>\n" all)))))
372 (replace 'bootstrap
373 (lambda _
374 (invoke "autoreconf" "-vfi")))
375 (add-after 'unpack 'move-info-location
376 ;; Build process installs info file in the unusual
377 ;; "%out/share/info/asymptote/" location. Move it to
378 ;; "%out/share/info/" so it appears in the top-level directory.
379 (lambda _
380 (substitute* "doc/png/Makefile.in"
381 (("(\\$\\(infodir\\))/asymptote" _ infodir) infodir))
382 (substitute* "doc/asymptote.texi"
383 (("asymptote/asymptote") "asymptote"))))
384 (add-before 'build 'patch-pdf-viewer
385 (lambda _
386 ;; Default to a free pdf viewer.
387 (substitute* "settings.cc"
388 (("defaultPDFViewer=\"acroread\"")
389 "defaultPDFViewer=\"gv\""))))
390 (add-before 'check 'set-HOME
391 ;; Some tests require write access to $HOME, otherwise leading to
392 ;; "failed to create directory /homeless-shelter/.asy" error.
393 (lambda _
394 (setenv "HOME" "/tmp")))
395 (add-after 'install 'install-Emacs-data
396 (lambda* (#:key outputs #:allow-other-keys)
397 ;; Install related Emacs libraries into an appropriate location.
398 (let ((lisp-dir
399 (string-append #$output "/share/emacs/site-lisp")))
400 (for-each (cut install-file <> lisp-dir)
401 (find-files "." "\\.el$"))
402 (emacs-generate-autoloads #$name lisp-dir))))
403 (add-after 'install-Emacs-data 'wrap-python-script
404 (lambda* (#:key inputs outputs #:allow-other-keys)
405 ;; Make sure 'xasy' runs with the correct PYTHONPATH.
406 (let ((path (getenv "GUIX_PYTHONPATH")))
407 (wrap-program
408 (string-append #$output "/share/asymptote/GUI/xasy.py")
409 `("GUIX_PYTHONPATH" ":" prefix (,path)))))))))
410 (home-page "http://asymptote.sourceforge.net")
411 (synopsis "Script-based vector graphics language")
412 (description
413 "Asymptote is a powerful descriptive vector graphics language for
414 technical drawing, inspired by MetaPost but with an improved C++-like syntax.
415 Asymptote provides for figures the same high-quality level of typesetting that
416 LaTeX does for scientific text.")
417 ;; Most source files do not contain license statements, but the README
418 ;; contains: "All source files in the Asymptote project, unless explicitly
419 ;; noted otherwise, are released under version 3 (or later) of the GNU
420 ;; Lesser General Public License"
421 (license license:lgpl3+)))