1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016, 2018 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages python-science)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages)
#:use-module (gnu packages base)
#:use-module (gnu packages check)
#:use-module (gnu packages gcc)
#:use-module (gnu packages maths)
#:use-module (gnu packages perl)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages sphinx)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system python))
(define-public python-scipy
(package
(name "python-scipy")
(version "1.3.2")
(source
(origin
(method url-fetch)
(uri (pypi-uri "scipy" version))
(sha256
(base32 "192d8dsybvhv19igkrsafbdafx198nz7pibkjgrqjhlr66s3jfd0"))))
(build-system python-build-system)
(propagated-inputs
`(("python-numpy" ,python-numpy)
("python-matplotlib" ,python-matplotlib)
("python-pyparsing" ,python-pyparsing)))
(inputs
`(("lapack" ,lapack)
("openblas" ,openblas)))
(native-inputs
`(("python-cython" ,python-cython)
("python-pytest" ,python-pytest)
("python-sphinx" ,python-sphinx)
("python-numpydoc" ,python-numpydoc)
("gfortran" ,gfortran)
("perl" ,perl)
("which" ,which)))
(outputs '("out" "doc"))
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'disable-broken-tests
(lambda _
(substitute* "scipy/sparse/linalg/dsolve/tests/test_linsolve.py"
(("^( +)def test_threads_parallel\\(self\\):" m indent)
(string-append indent
"@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
m)))
(substitute* "scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py"
(("^def test_parallel_threads\\(\\):" m)
(string-append "@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
m)))
#t))
(add-before 'build 'configure-openblas
(lambda* (#:key inputs #:allow-other-keys)
(call-with-output-file "site.cfg"
(lambda (port)
(format port
"[blas]
libraries = openblas
library_dirs = ~a/lib
include_dirs = ~a/include
# backslash-n to make emacs happy
\n[atlas]
library_dirs = ~a/lib
atlas_libs = openblas
"
(assoc-ref inputs "openblas")
(assoc-ref inputs "openblas")
(assoc-ref inputs "openblas"))))
#t))
(add-after 'install 'install-doc
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((data (string-append (assoc-ref outputs "doc") "/share"))
(doc (string-append data "/doc/" ,name "-" ,version))
(html (string-append doc "/html"))
(pyver ,(string-append "PYVER=" (version-major+minor
(package-version python))))
;; By default it tries to run sphinx-build through the Python
;; interpreter which won't work with our shell wrapper.
(sphinxbuild "SPHINXBUILD=LANG=C sphinx-build"))
;; Make installed package available for building the
;; documentation
(add-installed-pythonpath inputs outputs)
(with-directory-excursion "doc"
;; Fix generation of images for mathematical expressions.
(substitute* (find-files "source" "conf\\.py")
(("pngmath_use_preview = True")
"pngmath_use_preview = False"))
(mkdir-p html)
(invoke "make" "html" pyver sphinxbuild)
(with-directory-excursion "build/html"
(for-each (lambda (file)
(let* ((dir (dirname file))
(tgt-dir (string-append html "/" dir)))
(install-file file html)))
(find-files "." ".*")))))
#t))
;; Tests can only be run after the library has been installed and not
;; within the source directory.
(delete 'check)
(add-after 'install 'check
(lambda* (#:key inputs outputs #:allow-other-keys)
(add-installed-pythonpath inputs outputs)
(with-directory-excursion "/tmp"
(invoke "python" "-c"
"import scipy; scipy.test(verbose=2)")))))))
(home-page "https://www.scipy.org/")
(synopsis "The Scipy library provides efficient numerical routines")
(description "The SciPy library is one of the core packages that make up
the SciPy stack. It provides many user-friendly and efficient numerical
routines such as routines for numerical integration and optimization.")
(properties `((python2-variant . ,(delay python2-scipy))))
(license license:bsd-3)))
;; Version 1.2.2 is the last version to support Python 2
(define-public python2-scipy
(package
(inherit (package-with-python2
(strip-python2-variant python-scipy)))
(version "1.2.2")
(source
(origin
(method url-fetch)
(uri (pypi-uri "scipy" version))
(sha256
(base32
"1cgvgin8fvckv96hjh3ikmwkra5rif51bdb75ifzf7xbil5iwcx4"))))))
(define-public python-scikit-image
(package
(name "python-scikit-image")
(version "0.14.2")
(source
(origin
(method url-fetch)
(uri (pypi-uri "scikit-image" version))
(sha256
(base32 "07qchljkyxvg5nrm12fvszi7pmjk4m01qp0w0z8syxzxxs20pz8s"))))
(build-system python-build-system)
(arguments
;; TODO: Some tests require running X11 server. Disable them?
'(#:tests? #f))
;; See DEPENDS.txt for the list of build and run time requiremnts
(propagated-inputs
`(("python-cloudpickle" ,python-cloudpickle)
("python-dask" ,python-dask)
("python-matplotlib" ,python-matplotlib)
("python-networkx" ,python-networkx)
("python-numpy" ,python-numpy)
("python-pillow" ,python-pillow)
("python-pywavelets" ,python-pywavelets)
("python-scipy" ,python-scipy)
("python-six" ,python-six)))
(native-inputs
`(("python-cython" ,python-cython)))
(home-page "http://scikit-image.org/")
(synopsis "Image processing in Python")
(description
"Scikit-image is a collection of algorithms for image processing.")
(license license:bsd-3)))
(define-public python2-scikit-image
(package-with-python2 python-scikit-image))
|