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