~ruther/guix-local

c9abfacd9f58f7365668b67a8125640b7497932a — Sharlatan Hellseher 1 year, 5 months ago 0caba8f
gnu: Add python-numpy-2.

Test suite for NumPy@2.2.2 is heavily depends on included vendored-meson
sub-package and all of the tests fail.  This variant provides a working
NumPy, with passed build and sanity-check phases and tests disabled; it
allows users to include it in other package(s) where version 2+ is hard
required e.g. SageMath or Astropy@7.

* gnu/packages/python-xyz.scm (python-numpy-2): New variable.

Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Change-Id: I07e7aac8c1bf7e686b1c543a11f9ecbf682d6ad5
1 files changed, 69 insertions(+), 0 deletions(-)

M gnu/packages/python-xyz.scm
M gnu/packages/python-xyz.scm => gnu/packages/python-xyz.scm +69 -0
@@ 9447,6 9447,75 @@ capabilities.")
     '((upstream-name . "numpy")))
    (license license:bsd-3)))

(define-public python-numpy-2
  (package
    (inherit python-numpy)
    (name "python-numpy")
    (version "2.2.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://github.com/numpy/numpy/releases/download/v"
             version "/numpy-" version ".tar.gz"))
       (sha256
        (base32
         "13sdvwiqn85vw1dn1k1nd5ihadv82zhqm615imrqgmil33v0csgd"))))
    (arguments
     (list
      ;; TODO: Tests fail on setup, there is some issue with vendored-meson.
      #:tests? #f 
      #:modules '((guix build utils)
                  (guix build pyproject-build-system)
                  (ice-9 format))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'fix-executable-paths
            (lambda _
              (substitute* "numpy/distutils/exec_command.py"
                (("'/bin/sh'")
                 (format #f "~s" (which "bash"))))))
          (add-before 'build 'parallelize-build
            (lambda _
              (setenv "OMP_NUM_THREAD"
                      (number->string (parallel-job-count)))
              (setenv "NPY_NUM_BUILD_JOBS"
                      (number->string (parallel-job-count)))))
          ;; XXX: It fails with an issue "'fenv_t' has not been declared..."
          ;; when the gfortran header is used.  Remove gfortran from
          ;; CPLUS_INCLUDE_PATH as a workaround.  Taken from
          ;; <https://issues.guix.gnu.org/73439#45>.
          (add-after 'set-paths 'hide-gfortran
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((gfortran (assoc-ref inputs "gfortran")))
                (setenv "CPLUS_INCLUDE_PATH"
                        (string-join
                         (delete (string-append gfortran "/include/c++")
                                 (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))
                         ":")))))
          (add-before 'build 'configure-blas
            (lambda* (#:key inputs #:allow-other-keys)
              (call-with-output-file "site.cfg"
                (lambda (port)
                  (format port
                          "[openblas]
libraries = openblas
library_dirs = ~a/lib
include_dirs = ~:*~a/include~%" #$(this-package-input "openblas")))))))))
    (native-inputs
     (list gfortran
           meson-python
           ninja
           pkg-config
           python-hypothesis
           python-mypy
           python-pytest
           python-pytest-xdist
           python-setuptools
           python-setuptools
           python-typing-extensions
           python-wheel))))

(define-public python-numpy-documentation
  (package
    (inherit python-numpy)