gnu: stylish-haskell: Update description.
[jackhill/guix/guix.git] / gnu / packages / python-science.scm
CommitLineData
ca7c3653 1;;; GNU Guix --- Functional package management for GNU
312ec128 2;;; Copyright © 2015, 2016 Ricardo Wurmus <rekado@elephly.net>
ca7c3653 3;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
312ec128 4;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
ca7c3653
RW
5;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
6;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
39877154 7;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
ca7c3653 8;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
312ec128
RW
9;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
10;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
ca7c3653
RW
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 python-science)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (gnu packages)
ec1224a7
RW
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages check)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages maths)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages python)
312ec128 36 #:use-module (gnu packages python-web)
ca7c3653 37 #:use-module (gnu packages python-xyz)
ec1224a7 38 #:use-module (gnu packages sphinx)
312ec128 39 #:use-module (gnu packages time)
55e1475c 40 #:use-module (gnu packages xml)
ca7c3653
RW
41 #:use-module (guix packages)
42 #:use-module (guix download)
43 #:use-module (guix utils)
44 #:use-module (guix build-system python))
45
ec1224a7
RW
46(define-public python-scipy
47 (package
48 (name "python-scipy")
49 (version "1.3.2")
50 (source
51 (origin
52 (method url-fetch)
53 (uri (pypi-uri "scipy" version))
54 (sha256
55 (base32 "192d8dsybvhv19igkrsafbdafx198nz7pibkjgrqjhlr66s3jfd0"))))
56 (build-system python-build-system)
57 (propagated-inputs
58 `(("python-numpy" ,python-numpy)
59 ("python-matplotlib" ,python-matplotlib)
60 ("python-pyparsing" ,python-pyparsing)))
61 (inputs
62 `(("lapack" ,lapack)
63 ("openblas" ,openblas)))
64 (native-inputs
65 `(("python-cython" ,python-cython)
66 ("python-pytest" ,python-pytest)
67 ("python-sphinx" ,python-sphinx)
68 ("python-numpydoc" ,python-numpydoc)
69 ("gfortran" ,gfortran)
70 ("perl" ,perl)
71 ("which" ,which)))
72 (outputs '("out" "doc"))
73 (arguments
74 `(#:phases
75 (modify-phases %standard-phases
76 (add-after 'unpack 'disable-broken-tests
77 (lambda _
78 (substitute* "scipy/sparse/linalg/dsolve/tests/test_linsolve.py"
79 (("^( +)def test_threads_parallel\\(self\\):" m indent)
80 (string-append indent
81 "@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
82 m)))
83 (substitute* "scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py"
84 (("^def test_parallel_threads\\(\\):" m)
85 (string-append "@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
86 m)))
87 #t))
88 (add-before 'build 'configure-openblas
89 (lambda* (#:key inputs #:allow-other-keys)
90 (call-with-output-file "site.cfg"
91 (lambda (port)
92 (format port
93 "[blas]
94libraries = openblas
95library_dirs = ~a/lib
96include_dirs = ~a/include
97
98# backslash-n to make emacs happy
99\n[atlas]
100library_dirs = ~a/lib
101atlas_libs = openblas
102"
103 (assoc-ref inputs "openblas")
104 (assoc-ref inputs "openblas")
105 (assoc-ref inputs "openblas"))))
106 #t))
107 (add-after 'install 'install-doc
108 (lambda* (#:key inputs outputs #:allow-other-keys)
109 (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
110 (doc (string-append data "/doc/" ,name "-" ,version))
111 (html (string-append doc "/html"))
112 (pyver ,(string-append "PYVER=" (version-major+minor
113 (package-version python))))
114 ;; By default it tries to run sphinx-build through the Python
115 ;; interpreter which won't work with our shell wrapper.
116 (sphinxbuild "SPHINXBUILD=LANG=C sphinx-build"))
117 ;; Make installed package available for building the
118 ;; documentation
119 (add-installed-pythonpath inputs outputs)
120 (with-directory-excursion "doc"
121 ;; Fix generation of images for mathematical expressions.
122 (substitute* (find-files "source" "conf\\.py")
123 (("pngmath_use_preview = True")
124 "pngmath_use_preview = False"))
125 (mkdir-p html)
126 (invoke "make" "html" pyver sphinxbuild)
127 (with-directory-excursion "build/html"
128 (for-each (lambda (file)
129 (let* ((dir (dirname file))
130 (tgt-dir (string-append html "/" dir)))
131 (install-file file html)))
132 (find-files "." ".*")))))
133 #t))
134 ;; Tests can only be run after the library has been installed and not
135 ;; within the source directory.
136 (delete 'check)
137 (add-after 'install 'check
138 (lambda* (#:key inputs outputs #:allow-other-keys)
139 (add-installed-pythonpath inputs outputs)
140 (with-directory-excursion "/tmp"
141 (invoke "python" "-c"
142 "import scipy; scipy.test(verbose=2)")))))))
143 (home-page "https://www.scipy.org/")
144 (synopsis "The Scipy library provides efficient numerical routines")
145 (description "The SciPy library is one of the core packages that make up
146the SciPy stack. It provides many user-friendly and efficient numerical
147routines such as routines for numerical integration and optimization.")
148 (properties `((python2-variant . ,(delay python2-scipy))))
149 (license license:bsd-3)))
150
151;; Version 1.2.2 is the last version to support Python 2
152(define-public python2-scipy
153 (package
154 (inherit (package-with-python2
155 (strip-python2-variant python-scipy)))
156 (version "1.2.2")
157 (source
158 (origin
159 (method url-fetch)
160 (uri (pypi-uri "scipy" version))
161 (sha256
162 (base32
163 "1cgvgin8fvckv96hjh3ikmwkra5rif51bdb75ifzf7xbil5iwcx4"))))))
164
ca7c3653
RW
165(define-public python-scikit-image
166 (package
167 (name "python-scikit-image")
168 (version "0.14.2")
169 (source
170 (origin
171 (method url-fetch)
172 (uri (pypi-uri "scikit-image" version))
173 (sha256
174 (base32 "07qchljkyxvg5nrm12fvszi7pmjk4m01qp0w0z8syxzxxs20pz8s"))))
175 (build-system python-build-system)
176 (arguments
177 ;; TODO: Some tests require running X11 server. Disable them?
178 '(#:tests? #f))
179 ;; See DEPENDS.txt for the list of build and run time requiremnts
180 (propagated-inputs
181 `(("python-cloudpickle" ,python-cloudpickle)
182 ("python-dask" ,python-dask)
183 ("python-matplotlib" ,python-matplotlib)
184 ("python-networkx" ,python-networkx)
185 ("python-numpy" ,python-numpy)
186 ("python-pillow" ,python-pillow)
187 ("python-pywavelets" ,python-pywavelets)
188 ("python-scipy" ,python-scipy)
189 ("python-six" ,python-six)))
190 (native-inputs
191 `(("python-cython" ,python-cython)))
082c733c 192 (home-page "https://scikit-image.org/")
ca7c3653
RW
193 (synopsis "Image processing in Python")
194 (description
195 "Scikit-image is a collection of algorithms for image processing.")
196 (license license:bsd-3)))
197
198(define-public python2-scikit-image
199 (package-with-python2 python-scikit-image))
312ec128
RW
200
201(define-public python-pandas
202 (package
203 (name "python-pandas")
204 (version "0.25.2")
205 (source
206 (origin
207 (method url-fetch)
208 (uri (pypi-uri "pandas" version))
209 (sha256
210 (base32 "1gp2pvzdiakvgjmykdzdlzrsfbg4vjm49jjdl9s0ha0a3yfs34fa"))))
211 (build-system python-build-system)
212 (arguments
213 `(#:modules ((guix build utils)
214 (guix build python-build-system)
215 (ice-9 ftw)
216 (srfi srfi-26))
217 #:phases (modify-phases %standard-phases
218 (add-after 'unpack 'patch-which
219 (lambda* (#:key inputs #:allow-other-keys)
220 (let ((which (assoc-ref inputs "which")))
221 (substitute* "pandas/io/clipboard/__init__.py"
222 (("^CHECK_CMD = .*")
223 (string-append "CHECK_CMD = \"" which "\"\n"))))
224 #t))
225 (replace 'check
226 (lambda _
227 (let ((build-directory
228 (string-append
229 (getcwd) "/build/"
230 (car (scandir "build"
231 (cut string-prefix? "lib." <>))))))
232 ;; Disable the "strict data files" option which causes
233 ;; the build to error out if required data files are
234 ;; not available (as is the case with PyPI archives).
235 (substitute* "setup.cfg"
236 (("addopts = --strict-data-files") "addopts = "))
237 (with-directory-excursion build-directory
238 ;; Delete tests that require "moto" which is not yet
239 ;; in Guix.
240 (for-each delete-file
241 '("pandas/tests/io/conftest.py"
242 "pandas/tests/io/json/test_compression.py"
243 "pandas/tests/io/parser/test_network.py"
244 "pandas/tests/io/test_parquet.py"))
245 (invoke "pytest" "-vv" "pandas" "--skip-slow"
246 "--skip-network" "-k"
247 ;; XXX: Due to the deleted tests above.
248 "not test_read_s3_jsonl"))))))))
249 (propagated-inputs
250 `(("python-numpy" ,python-numpy)
251 ("python-openpyxl" ,python-openpyxl)
252 ("python-pytz" ,python-pytz)
253 ("python-dateutil" ,python-dateutil)
254 ("python-xlrd" ,python-xlrd)))
255 (inputs
256 `(("which" ,which)))
257 (native-inputs
258 `(("python-cython" ,python-cython)
259 ("python-beautifulsoup4" ,python-beautifulsoup4)
260 ("python-lxml" ,python-lxml)
261 ("python-html5lib" ,python-html5lib)
262 ("python-nose" ,python-nose)
263 ("python-pytest" ,python-pytest)
264 ("python-pytest-mock" ,python-pytest-mock)))
265 (home-page "https://pandas.pydata.org")
266 (synopsis "Data structures for data analysis, time series, and statistics")
267 (description
268 "Pandas is a Python package providing fast, flexible, and expressive data
269structures designed to make working with structured (tabular,
270multidimensional, potentially heterogeneous) and time series data both easy
271and intuitive. It aims to be the fundamental high-level building block for
272doing practical, real world data analysis in Python.")
273 (properties `((python2-variant . ,(delay python2-pandas))))
274 (license license:bsd-3)))
275
276;; Pandas 0.24.x are the last versions that support Python 2.
277(define-public python2-pandas
278 (let ((pandas (package-with-python2
279 (strip-python2-variant python-pandas))))
39877154
MB
280 (package
281 (inherit pandas)
282 (version "0.24.2")
283 (source (origin
284 (method url-fetch)
285 (uri (pypi-uri "pandas" version))
286 (sha256
287 (base32
288 "18imlm8xbhcbwy4wa957a1fkamrcb0z988z006jpfda3ki09z4ag"))
289 (modules '((guix build utils)))
290 (snippet
291 '(begin
292 ;; Adjust for renamed error message in Python 2.7.17. Taken
293 ;; from <https://github.com/pandas-dev/pandas/pull/29294>.
294 (substitute* "pandas/io/parsers.py"
295 (("if 'NULL byte' in msg:")
296 "if 'NULL byte' in msg or 'line contains NUL' in msg:"))
297 #t)))))))