me
/
guix
Archived
1
0
Fork 0

gnu: python-numpy: Update to 1.21.6 and parallelize build/tests.

* gnu/packages/python-xyz.scm (python-numpy): Update to 1.21.6.  Move inputs
and native-inputs fields after arguments.  Use gexps.
[modules]: New argument.
[phases]{parallelize-build}: New phase.
{configure-blas}: Format via (ice-9 format).
{fix-executable-paths}: Use search-file-input.  Remove obsolete system_info.py
substitution.
{check}: Remove extraneous add-installed-pythonpath and setenv calls.  Provide
the '-n' pytest-xdist option.
[native-inputs]: Use python-hypothesis-next.
(python-numpy-next): Inherit from python-numpy.
(python2-numpy): Adjust for gexps.
[phases]{delete-failing-test}: Rename to...
{delete-failing-tests}: ... this.
(python2-numpy-1.8): Likewise, and delete 'delete-failing-tests' phase.
Disable tests.
[native-inputs]: Define as the empty list.
master
Maxim Cournoyer 2022-04-18 14:28:31 -04:00
parent bfe7f40650
commit 411cd4345f
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 93 additions and 101 deletions

View File

@ -5703,10 +5703,13 @@ writing C extensions for Python as easy as Python itself.")
"17fqacrpis05w1rpi7d7sbimrk20xf8h6d3vrz5nf6ix3899abil")))) "17fqacrpis05w1rpi7d7sbimrk20xf8h6d3vrz5nf6ix3899abil"))))
(properties '()))) (properties '())))
(define-public python-numpy-next ;; NOTE: when upgrading numpy please make sure that python-numba,
;; python-pandas and python-scipy still build, as these three packages are
;; often used together.
(define-public python-numpy
(package (package
(name "python-numpy-next") (name "python-numpy")
(version "1.22.3") (version "1.21.6")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
@ -5715,50 +5718,57 @@ writing C extensions for Python as easy as Python itself.")
version "/numpy-" version ".tar.gz")) version "/numpy-" version ".tar.gz"))
(sha256 (sha256
(base32 (base32
"19dw91pqbqcniw2z57kiyqs1qp56g7kqy1bdyv664g8s62sc01m9")))) "0b0c5y35rd3mvwfk5is1d5ppfw9nl4d2rgx9xkwh1p0w394wdvyl"))))
(build-system python-build-system) (build-system python-build-system)
(inputs
(list openblas))
(native-inputs
(list python-cython python-hypothesis-6.23 python-pytest
python-pytest-xdist gfortran))
(arguments (arguments
`(#:phases (list
(modify-phases %standard-phases #:modules '((guix build utils)
(add-before 'build 'configure-blas (guix build python-build-system)
(lambda* (#:key inputs #:allow-other-keys) (ice-9 format))
(call-with-output-file "site.cfg" #:phases
(lambda (port) #~(modify-phases %standard-phases
(format port (add-before 'build 'parallelize-build
"\ (lambda _
(setenv "NPY_NUM_BUILD_JOBS"
(number->string (parallel-job-count)))))
(add-before 'build 'configure-blas
(lambda* (#:key inputs #:allow-other-keys)
(call-with-output-file "site.cfg"
(lambda (port)
(format port
"\
[openblas] [openblas]
libraries = openblas libraries = openblas
library_dirs = ~a/lib library_dirs = ~a/lib
include_dirs = ~a/include include_dirs = ~:*~a/include~%" #$(this-package-input "openblas"))))))
" (add-before 'build 'fix-executable-paths
(assoc-ref inputs "openblas") (lambda* (#:key inputs #:allow-other-keys)
(assoc-ref inputs "openblas")))))) ;; Make /gnu/store/...-bash-.../bin/sh the default shell,
(add-before 'build 'fix-executable-paths ;; instead of /bin/sh.
(lambda* (#:key inputs #:allow-other-keys) (substitute* "numpy/distutils/exec_command.py"
;; Make /gnu/store/...-bash-.../bin/sh the default shell, (("'/bin/sh'")
;; instead of /bin/sh. (format #f "~s" (search-input-file inputs "bin/bash"))))))
(substitute* "numpy/distutils/exec_command.py" (replace 'check
(("(os.environ.get\\('SHELL', ')(/bin/sh'\\))" match match-start match-end) (lambda* (#:key tests? outputs inputs #:allow-other-keys)
(string-append match-start (assoc-ref inputs "bash") match-end))) (when tests?
;; Use "gcc" executable, not "cc". (invoke "./runtests.py" "-vv" "--no-build" "--mode=fast"
(substitute* "numpy/distutils/system_info.py" "-j" (number->string (parallel-job-count))
(("c = distutils\\.ccompiler\\.new_compiler\\(\\)") ;; Contrary to scipy, the runtests.py script of numpy
"c = distutils.ccompiler.new_compiler(); c.set_executables(compiler='gcc',compiler_so='gcc',linker_exe='gcc',linker_so='gcc -shared')")))) ;; does *not* automatically provide -n when -j is used
(replace 'check ;; (see: https://github.com/numpy/numpy/issues/21359).
(lambda* (#:key tests? outputs inputs #:allow-other-keys) "--" "-n" (number->string (parallel-job-count))
(when tests? "-k" (string-append
;; Make installed package available for running the tests. ;; These tests may fail on 32-bit systems (see:
(add-installed-pythonpath inputs outputs) ;; https://github.com/numpy/numpy/issues/18387).
;; Make sure "f2py" etc is found. "not test_float_remainder_overflow "
(setenv "PATH" (string-append (assoc-ref outputs "out") "/bin" "and not test_pareto"))))))))
":" (getenv "PATH"))) (native-inputs
(invoke "./runtests.py" (list python-cython
"-j" (number->string (parallel-job-count))))))))) python-hypothesis-next
python-pytest
python-pytest-xdist
gfortran))
(inputs (list bash openblas))
(home-page "https://numpy.org") (home-page "https://numpy.org")
(synopsis "Fundamental package for scientific computing with Python") (synopsis "Fundamental package for scientific computing with Python")
(description "NumPy is the fundamental package for scientific computing (description "NumPy is the fundamental package for scientific computing
@ -5769,10 +5779,26 @@ capabilities.")
(properties `((python2-variant . ,(delay python2-numpy)))) (properties `((python2-variant . ,(delay python2-numpy))))
(license license:bsd-3))) (license license:bsd-3)))
(define-public python-numpy-next
(package
(inherit python-numpy)
(name "python-numpy-next")
(version "1.22.3")
(source
(origin
(inherit (package-source python-numpy))
(method url-fetch)
(uri (string-append
"https://github.com/numpy/numpy/releases/download/v"
version "/numpy-" version ".tar.gz"))
(sha256
(base32
"19dw91pqbqcniw2z57kiyqs1qp56g7kqy1bdyv664g8s62sc01m9"))))))
;; Numpy 1.16.x are the last versions that support Python 2. ;; Numpy 1.16.x are the last versions that support Python 2.
(define-public python2-numpy (define-public python2-numpy
(let ((numpy (package-with-python2 (let ((numpy (package-with-python2
(strip-python2-variant python-numpy-next)))) (strip-python2-variant python-numpy))))
(package (package
(inherit numpy) (inherit numpy)
(name "python2-numpy") (name "python2-numpy")
@ -5788,80 +5814,46 @@ capabilities.")
(arguments (arguments
(substitute-keyword-arguments (package-arguments numpy) (substitute-keyword-arguments (package-arguments numpy)
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases #~(modify-phases #$phases
(add-after 'unpack 'delete-failing-test (add-after 'unpack 'delete-failing-tests
(lambda _ (lambda _
;; There's just one failing test here. ;; There's just one failing test here.
(delete-file "numpy/linalg/tests/test_linalg.py") (delete-file "numpy/linalg/tests/test_linalg.py")
;; ...and this one depends on the previous one. ;; ...and this one depends on the previous one.
(delete-file "numpy/matrixlib/tests/test_matrix_linalg.py"))))))) (delete-file "numpy/matrixlib/tests/test_matrix_linalg.py")))
(replace 'check
;; Older versions don't cope well with the extra Pytest
;; options, so remove them.
(lambda* (#:key tests? outputs inputs #:allow-other-keys)
(when tests?
(invoke "./runtests.py" "-vv" "--no-build" "--mode=fast"
"-j" (number->string (parallel-job-count))))))))))
(native-inputs (native-inputs
(list python2-cython python2-pytest gfortran))))) (list python2-cython python2-pytest gfortran)))))
;; Needed by python-numba, see https://github.com/numba/numba/issues/7176
(define-public python-numpy-1.20
(package
(inherit python-numpy-next)
(name "python-numpy")
(version "1.20.3")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/numpy/numpy/releases/download/v"
version "/numpy-" version ".tar.gz"))
(sha256
(base32
"140zq9snx0di4id4g97vaw9zz8x2rfla5lp3a70j666f5030yd5p"))))
;; python-numpy-next replaced python-hypothesis with
;; python-hypothesis-6.23. We switch it back here, to prevent
;; python-numpy-1.20 and its numerous dependents from being rebuilt.
(native-inputs
(list python-cython python-hypothesis python-pytest
python-pytest-xdist gfortran))
;; 92 tests fail, many of them because parts of the temp file name
;; accidentally ends up in a comparison.
(arguments
(substitute-keyword-arguments (package-arguments python-numpy-next)
((#:tests? _ #t) #f)))))
;; NOTE: when upgrading numpy please make sure that python-pandas and
;; python-scipy still build, as these three packages are often used together.
(define-public python-numpy python-numpy-1.20)
;; NOTE: NumPy 1.8 is packaged only for Python 2 because it is of ;; NOTE: NumPy 1.8 is packaged only for Python 2 because it is of
;; interest only for legacy code going back to NumPy's predecessor ;; interest only for legacy code going back to NumPy's predecessor
;; Numeric. ;; Numeric.
(define-public python2-numpy-1.8 (define-public python2-numpy-1.8
(package (inherit python2-numpy) (package
(inherit python2-numpy)
(version "1.8.2") (version "1.8.2")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
(url "https://github.com/numpy/numpy") (url "https://github.com/numpy/numpy")
(commit (string-append "v" version)))) (commit (string-append "v" version))))
(file-name (git-file-name "numpy" version)) (file-name (git-file-name "numpy" version))
(sha256 (sha256
(base32 (base32
"0ikgi15rsqwbkfsjjxrwh40lqyal2wvyp3923y6w6ch3dcr82sfk")))) "0ikgi15rsqwbkfsjjxrwh40lqyal2wvyp3923y6w6ch3dcr82sfk"))))
(arguments (arguments (substitute-keyword-arguments (package-arguments python2-numpy)
(substitute-keyword-arguments (package-arguments python2-numpy) ((#:tests? _ #f) #f) ;disable tests
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases #~(modify-phases #$phases
(replace 'configure-blas (delete 'delete-failing-tests)))))
(lambda* (#:key inputs #:allow-other-keys) (native-inputs '())
(call-with-output-file "site.cfg"
(lambda (port)
(format port
"[openblas]
libraries = openblas
library_dirs = ~a/lib
include_dirs = ~a/include
"
(assoc-ref inputs "openblas")
(assoc-ref inputs "openblas"))))))))))
(native-inputs
(list python2-nose))
(description "NumPy is the fundamental package for scientific computing (description "NumPy is the fundamental package for scientific computing
with Python. It contains among other things: a powerful N-dimensional array with Python. It contains among other things: a powerful N-dimensional array
object, sophisticated (broadcasting) functions, tools for integrating C/C++ object, sophisticated (broadcasting) functions, tools for integrating C/C++