Archived
1
0
Fork 0

gnu: petsc: Update to 3.16.1.

* gnu/packages/maths.scm (petsc): Update to 3.16.1.
[native-inputs]: Use PYTHON instead of PYTHON-2.  Add WHICH.
[arguments]: Rewrite using gexps.  Pass '--with-openblas-dir'.  In
'configure' phase, modify "config/example_template.py".
This commit is contained in:
Ludovic Courtès 2021-11-28 23:54:31 +01:00
parent 57b62e5bb9
commit 07ac13a26a
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -2870,7 +2870,7 @@ September 2004}")
(define-public petsc (define-public petsc
(package (package
(name "petsc") (name "petsc")
(version "3.11.2") (version "3.16.1")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
@ -2878,12 +2878,13 @@ September 2004}")
(uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/" (uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
"petsc-lite-" version ".tar.gz")) "petsc-lite-" version ".tar.gz"))
(sha256 (sha256
(base32 "1645nwwcp9bcnfnxikk480mhbbacdvhsay2c401818hk97dqj5nx")))) (base32 "0sm03vpg010q9icidiq587n325m0598cj6hab2rdv85nwyygg74h"))))
(outputs '("out" ; libraries and headers (outputs '("out" ; libraries and headers
"examples")) ; ~30MiB of examples "examples")) ; ~30MiB of examples
(build-system gnu-build-system) (build-system gnu-build-system)
(native-inputs (native-inputs
`(("python" ,python-2))) `(("python" ,python)
("which" ,which)))
(inputs (inputs
`(("gfortran" ,gfortran) `(("gfortran" ,gfortran)
("openblas" ,openblas) ("openblas" ,openblas)
@ -2892,75 +2893,80 @@ September 2004}")
;; leaving out opengl, as configuration seems to only be for mac ;; leaving out opengl, as configuration seems to only be for mac
)) ))
(arguments (arguments
`(#:test-target "test" (list
#:parallel-build? #f ; build is parallel by default #:test-target "test"
#:configure-flags #:parallel-build? #f ; build is parallel by default
`("--with-mpi=0" #:configure-flags
"--with-openmp=1" #~(list "--with-mpi=0"
"--with-openblas=1" "--with-openmp=1"
"--with-superlu=1") "--with-openblas=1"
#:make-flags (string-append "--with-openblas-dir="
;; Honor (parallel-job-count) for build. Do not use --with-make-np, #$(this-package-input "openblas"))
;; whose value is dumped to $out/lib/petsc/conf/petscvariables. "--with-superlu=1")
(list (format #f "MAKE_NP=~a" (parallel-job-count))) #:make-flags
#:phases ;; Honor (parallel-job-count) for build. Do not use --with-make-np,
(modify-phases %standard-phases ;; whose value is dumped to $out/lib/petsc/conf/petscvariables.
(replace 'configure #~(list (format #f "MAKE_NP=~a" (parallel-job-count)))
;; PETSc's configure script is actually a python script, so we can't #:phases
;; run it with bash. #~(modify-phases %standard-phases
(lambda* (#:key outputs (configure-flags '()) (replace 'configure
#:allow-other-keys) ;; PETSc's configure script is actually a python script, so we can't
(let* ((prefix (assoc-ref outputs "out")) ;; run it with bash.
(flags `(,(string-append "--prefix=" prefix) (lambda* (#:key outputs (configure-flags '())
,@configure-flags))) #:allow-other-keys)
(format #t "build directory: ~s~%" (getcwd)) (let* ((prefix (assoc-ref outputs "out"))
(format #t "configure flags: ~s~%" flags) (flags `(,(string-append "--prefix=" prefix)
(apply invoke "./configure" flags)))) ,@configure-flags)))
(add-after 'configure 'clean-local-references (format #t "build directory: ~s~%" (getcwd))
(lambda* (#:key outputs #:allow-other-keys) (format #t "configure flags: ~s~%" flags)
(let ((out (assoc-ref outputs "out"))) (apply invoke "./configure" flags)
(substitute* (find-files "." "^petsc(conf|machineinfo).h$")
;; Prevent build directory from leaking into compiled code ;; Generate test scripts with the right shebang.
(((getcwd)) out) (substitute* "config/example_template.py"
;; Scrub timestamp for reproducibility (("#!/usr/bin/env bash")
((".*Libraries compiled on.*") "")) (string-append "#!" (which "bash")))))))
(substitute* (find-files "." "petscvariables") (add-after 'configure 'clean-local-references
;; Do not expose build machine characteristics, set to defaults. (lambda* (#:key outputs #:allow-other-keys)
(("MAKE_NP = [:digit:]+") "MAKE_NP = 2") (let ((out (assoc-ref outputs "out")))
(("NPMAX = [:digit:]+") "NPMAX = 2")) (substitute* (find-files "." "^petsc(conf|machineinfo).h$")
#t))) ;; Prevent build directory from leaking into compiled code
(add-after 'install 'clean-install (((getcwd)) out)
;; Try to keep installed files from leaking build directory names. ;; Scrub timestamp for reproducibility
(lambda* (#:key inputs outputs #:allow-other-keys) ((".*Libraries compiled on.*") ""))
(let ((out (assoc-ref outputs "out"))) (substitute* (find-files "." "petscvariables")
(substitute* (map (lambda (file) ;; Do not expose build machine characteristics, set to defaults.
(string-append out "/lib/petsc/conf/" file)) (("MAKE_NP = [:digit:]+") "MAKE_NP = 2")
'("petscvariables")) (("NPMAX = [:digit:]+") "NPMAX = 2")))))
(((getcwd)) out)) (add-after 'install 'clean-install
;; Make compiler references point to the store ;; Try to keep installed files from leaking build directory names.
(substitute* (string-append out "/lib/petsc/conf/petscvariables") (lambda* (#:key inputs outputs #:allow-other-keys)
(("= (gcc|g\\+\\+|gfortran)" _ compiler) (let ((out (assoc-ref outputs "out")))
(string-append "= " (which compiler)))) (substitute* (map (lambda (file)
;; PETSc installs some build logs, which aren't necessary. (string-append out "/lib/petsc/conf/" file))
(for-each (lambda (file) '("petscvariables"))
(let ((f (string-append out "/lib/petsc/conf/" file))) (((getcwd)) out))
(when (file-exists? f) ;; Make compiler references point to the store
(delete-file f)))) (substitute* (string-append out "/lib/petsc/conf/petscvariables")
'("configure.log" "make.log" "gmake.log" (("= (gcc|g\\+\\+|gfortran)" _ compiler)
"test.log" "error.log" "RDict.db" (string-append "= " (which compiler))))
"PETScBuildInternal.cmake" ;; PETSc installs some build logs, which aren't necessary.
;; Once installed, should uninstall with Guix (for-each (lambda (file)
"uninstall.py")) (let ((f (string-append out "/lib/petsc/conf/" file)))
#t))) (when (file-exists? f)
(add-after 'install 'move-examples (delete-file f))))
(lambda* (#:key outputs #:allow-other-keys) '("configure.log" "make.log" "gmake.log"
(let* ((out (assoc-ref outputs "out")) "test.log" "error.log" "RDict.db"
(examples (assoc-ref outputs "examples")) "PETScBuildInternal.cmake"
(exdir (string-append out "/share/petsc/examples")) ;; Once installed, should uninstall with Guix
(exdir' (string-append examples "/share/petsc/examples"))) "uninstall.py")))))
(copy-recursively exdir exdir') (add-after 'install 'move-examples
(delete-file-recursively exdir) (lambda* (#:key outputs #:allow-other-keys)
#t)))))) (let* ((out (assoc-ref outputs "out"))
(examples (assoc-ref outputs "examples"))
(exdir (string-append out "/share/petsc/examples"))
(exdir' (string-append examples "/share/petsc/examples")))
(copy-recursively exdir exdir')
(delete-file-recursively exdir)))))))
(home-page "https://www.mcs.anl.gov/petsc") (home-page "https://www.mcs.anl.gov/petsc")
(synopsis "Library to solve PDEs") (synopsis "Library to solve PDEs")
(description "PETSc, pronounced PET-see (the S is silent), is a suite of (description "PETSc, pronounced PET-see (the S is silent), is a suite of