gnu: python-scipy: Update to 1.8.0 and enable parallel build.

* gnu/packages/python-science.scm (python-scipy): Update to 1.8.0.
[modules]: New argument.
[phases]{disable-broken-tests}: Delete phase.
{configure-openblas}: Streamline configuration template.
{parallelize-build}: New phase.
{install-doc}: Move before 'check phase.  Remove now extraneous
'add-installed-pythonpath' call.  Remove the SPHINXBUILD and PYVER Make
variables, as well as conf.py patching.  Provide SPHINXOPTS to build doc in
parallel.  Simply recursively copy the 'html' output directory to install the
doc.
{check}: Remove extraneous INPUTS and OUTPUTS arguments.  Start tests with the
'runtests.py' launcher, which accepts a '-j' argument to run the tests in
parallel.
[native-inputs]: Sort inputs.  Add python-pytest-xdist and
python-threadpoolctl.
[home-page]: Update.
This commit is contained in:
Maxim Cournoyer 2022-04-06 22:24:48 -04:00
parent 5a3634f461
commit cddedb9c5b
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -73,17 +73,20 @@
(define-public python-scipy (define-public python-scipy
(package (package
(name "python-scipy") (name "python-scipy")
(version "1.7.3") (version "1.8.0")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
(uri (pypi-uri "scipy" version)) (uri (pypi-uri "scipy" version))
(sha256 (sha256
(base32 "1gxsnw6viz2j3sm8ak2a8l7fcn4b2zm3kzfm8w57xxyyrzx7an5b")))) (base32 "1gghkwn93niyasm36333xbqrnn3yiadq9d97wnc9mg14nzbg5m1i"))))
(outputs '("out" "doc")) (outputs '("out" "doc"))
(build-system python-build-system) (build-system python-build-system)
(arguments (arguments
(list (list
#:modules '((guix build utils)
(guix build python-build-system)
(ice-9 format))
#:phases #:phases
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'disable-pythran (add-after 'unpack 'disable-pythran
@ -93,81 +96,59 @@
(lambda _ (lambda _
;; Change from /homeless-shelter to /tmp for write permission. ;; Change from /homeless-shelter to /tmp for write permission.
(setenv "HOME" "/tmp"))) (setenv "HOME" "/tmp")))
(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)))))
(add-before 'build 'configure-openblas (add-before 'build 'configure-openblas
(lambda _ (lambda _
(call-with-output-file "site.cfg" (call-with-output-file "site.cfg"
(lambda (port) (lambda (port)
(format port (format port
"[blas] "\
[blas]
libraries = openblas libraries = openblas
library_dirs = ~a/lib library_dirs = ~a/lib
include_dirs = ~a/include include_dirs = ~:*~a/include
# backslash-n to make emacs happy [atlas]
\n[atlas] library_dirs = ~:*~a/lib
library_dirs = ~a/lib atlas_libs = openblas~%" #$(this-package-input "openblas"))))))
atlas_libs = openblas (add-before 'build 'parallelize-build
" (lambda _
#$(this-package-input "openblas") (setenv "NPY_NUM_BUILD_JOBS"
#$(this-package-input "openblas") (number->string (parallel-job-count)))))
#$(this-package-input "openblas")))))) (add-before 'check 'install-doc
(add-after 'install 'install-doc (lambda* (#:key outputs #:allow-other-keys)
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((data (string-append (assoc-ref outputs "doc") "/share")) (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
(doc (string-append data "/doc/" #$name "-" #$version)) (doc (string-append data "/doc/" #$name "-" #$version))
(html (string-append doc "/html")) (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" (with-directory-excursion "doc"
;; Fix generation of images for mathematical expressions. ;; Build doc.
(substitute* (find-files "source" "conf\\.py") (invoke "make" "html"
(("pngmath_use_preview = True") ;; Building the documentation takes a very long time.
"pngmath_use_preview = False")) ;; Parallelize it.
(string-append "SPHINXOPTS=-j"
(number->string (parallel-job-count))))
;; Install doc.
(mkdir-p html) (mkdir-p html)
(invoke "make" "html" pyver sphinxbuild) (copy-recursively "build/html" html)))))
(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 ".")))))))
(replace 'check (replace 'check
(lambda* (#:key tests? inputs outputs #:allow-other-keys) (lambda* (#:key tests? #:allow-other-keys)
(when tests? (when tests?
(with-directory-excursion "/tmp" (invoke "./runtests.py" "-vv" "--no-build" "--mode=fast"
(invoke "python" "-c" "-j" (number->string (parallel-job-count)))))))))
"import scipy; scipy.test(verbose=2)"))))))))
(propagated-inputs (list python-numpy python-matplotlib python-pyparsing)) (propagated-inputs (list python-numpy python-matplotlib python-pyparsing))
(inputs (list openblas pybind11)) (inputs (list openblas pybind11))
(native-inputs (native-inputs
(list python-cython (list gfortran
perl
python-cython
python-numpydoc
python-pydata-sphinx-theme python-pydata-sphinx-theme
python-pytest python-pytest
python-pytest-xdist
python-sphinx python-sphinx
python-sphinx-panels python-sphinx-panels
python-numpydoc python-threadpoolctl
gfortran
perl
which)) which))
(home-page "https://www.scipy.org/") (home-page "https://scipy.org/")
(synopsis "The Scipy library provides efficient numerical routines") (synopsis "The Scipy library provides efficient numerical routines")
(description "The SciPy library is one of the core packages that make up (description "The SciPy library is one of the core packages that make up
the SciPy stack. It provides many user-friendly and efficient numerical the SciPy stack. It provides many user-friendly and efficient numerical