| 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 | (define-module (gnu packages python-science)
|
| 28 | #:use-module ((guix licenses) #:prefix license:)
|
| 29 | #:use-module (gnu packages)
|
| 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)
|
| 36 | #:use-module (gnu packages python-web)
|
| 37 | #:use-module (gnu packages python-xyz)
|
| 38 | #:use-module (gnu packages sphinx)
|
| 39 | #:use-module (gnu packages time)
|
| 40 | #:use-module (gnu packages xml)
|
| 41 | #:use-module (guix packages)
|
| 42 | #:use-module (guix download)
|
| 43 | #:use-module (guix utils)
|
| 44 | #:use-module (guix build-system python))
|
| 45 |
|
| 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]
|
| 94 | libraries = openblas
|
| 95 | library_dirs = ~a/lib
|
| 96 | include_dirs = ~a/include
|
| 97 |
|
| 98 | # backslash-n to make emacs happy
|
| 99 | \n[atlas]
|
| 100 | library_dirs = ~a/lib
|
| 101 | atlas_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 | |
| 115 | |
| 116 | (sphinxbuild "SPHINXBUILD=LANG=C sphinx-build"))
|
| 117 | |
| 118 | |
| 119 | (add-installed-pythonpath inputs outputs)
|
| 120 | (with-directory-excursion "doc"
|
| 121 | |
| 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 | |
| 135 | |
| 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
|
| 146 | the SciPy stack. It provides many user-friendly and efficient numerical
|
| 147 | routines such as routines for numerical integration and optimization.")
|
| 148 | (properties `((python2-variant . ,(delay python2-scipy))))
|
| 149 | (license license:bsd-3)))
|
| 150 |
|
| 151 | |
| 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 |
|
| 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 | |
| 178 | '(#:tests? #f))
|
| 179 | |
| 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)))
|
| 192 | (home-page "https://scikit-image.org/")
|
| 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))
|
| 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 | |
| 233 | |
| 234 | |
| 235 | (substitute* "setup.cfg"
|
| 236 | (("addopts = --strict-data-files") "addopts = "))
|
| 237 | (with-directory-excursion build-directory
|
| 238 | |
| 239 | |
| 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 | |
| 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
|
| 269 | structures designed to make working with structured (tabular,
|
| 270 | multidimensional, potentially heterogeneous) and time series data both easy
|
| 271 | and intuitive. It aims to be the fundamental high-level building block for
|
| 272 | doing practical, real world data analysis in Python.")
|
| 273 | (properties `((python2-variant . ,(delay python2-pandas))))
|
| 274 | (license license:bsd-3)))
|
| 275 |
|
| 276 | |
| 277 | (define-public python2-pandas
|
| 278 | (let ((pandas (package-with-python2
|
| 279 | (strip-python2-variant python-pandas))))
|
| 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 | |
| 293 | |
| 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)))))))
|