From c9abfacd9f58f7365668b67a8125640b7497932a Mon Sep 17 00:00:00 2001 From: Sharlatan Hellseher Date: Fri, 24 Jan 2025 08:05:34 +0000 Subject: [PATCH] gnu: Add python-numpy-2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: I07e7aac8c1bf7e686b1c543a11f9ecbf682d6ad5 --- gnu/packages/python-xyz.scm | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index fcdc4387b33cf595a32810eee5d95f74cf2fedaf..a4017fffe486b3bc85105e4d3f83477aec51cb15 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -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 + ;; . + (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)