Archived
1
0
Fork 0

gnu: nomad-optimizer: Update to 4.3.1.

* gnu/packages/maths.scm (nomad-optimizer): Update to 4.3.1.
[native-inputs]: Remove python-wrapper and python-cython. Add openmpi.
[arguments]: Use G-expressions. Remove #:imported-modules and #:modules.
<#:configure-flags>: Remove -DBUILD_INTERFACE_PYTHON=ON.
<#:phases>: Remove 'fix-sources-for-build' phase. Rename
'fix-sources-for-tests' phase to 'fix-tests' and update it. Add
'mpi-setup' phase.

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Paul A. Patience 2023-10-10 17:27:45 +00:00 committed by Christopher Baines
parent 67dcc64110
commit 33cbb0ca8d
No known key found for this signature in database
GPG key ID: 5E28A33B0B84F577

View file

@ -2421,7 +2421,7 @@ interfaces.")
(define-public nomad-optimizer (define-public nomad-optimizer
(package (package
(name "nomad-optimizer") (name "nomad-optimizer")
(version "4.2.0") (version "4.3.1")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -2430,96 +2430,44 @@ interfaces.")
(commit (string-append "v." version)))) (commit (string-append "v." version))))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32 "08bxdvx8p5qzdw331xa5irc1896as4q5hajsid7f3qcxjm4nq4v3"))))
"1r4ygy3xn83dnppsw1451ynklsxpb238g5gk57inn84ghmdk08mj"))))
(build-system cmake-build-system) (build-system cmake-build-system)
(native-inputs (native-inputs
(list python-wrapper python-cython)) (list openmpi))
(arguments (arguments
`(#:imported-modules ((guix build python-build-system) (list
,@%cmake-build-system-modules) ;; Cannot build Python interface because it is incompatible with OpenMP
#:modules (((guix build python-build-system) ;; support, which is enabled by default.
#:select (python-version site-packages))
(guix build cmake-build-system)
(guix build utils))
#:configure-flags #:configure-flags
'("-DBUILD_INTERFACE_C=ON" #~(list "-DBUILD_TESTS=ON"
"-DBUILD_INTERFACE_PYTHON=ON" "-DBUILD_INTERFACE_C=ON")
"-DBUILD_TESTS=ON")
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'fix-sources-for-build (add-after 'unpack 'fix-tests
(lambda* (#:key outputs #:allow-other-keys)
(substitute* "CMakeLists.txt"
;; CMAKE_INSTALL_PREFIX is accidentally hardcoded.
(("set\\(CMAKE_INSTALL_PREFIX .* FORCE\\)") "")
;; Requiring GCC version 8 or later is unwarranted.
(("message\\(FATAL_ERROR \"GCC version < 8")
"message(STATUS \"GCC version < 8"))
(let ((out (assoc-ref outputs "out")))
(substitute* "interfaces/PyNomad/CMakeLists.txt"
;; We don't want to build in-place, and anyway the install
;; command further below runs build_ext as a prerequisite.
(("COMMAND python setup_PyNomad\\.py .* build_ext --inplace\n")
"")
;; Don't install locally.
(("COMMAND python (setup_PyNomad\\.py .* install) --user\n"
_ args)
(string-append "COMMAND ${CMAKE_COMMAND} -E env"
" CC=" ,(cc-for-target)
" CXX=" ,(cxx-for-target)
" " (which "python")
" " args
" --prefix=" out
"\n")))
;; Fix erroneous assumptions about the paths of the include and
;; library directories.
(substitute* "interfaces/PyNomad/setup_PyNomad.py"
(("^( +os_include_dirs = ).*" _ prefix)
(string-append prefix "[\"../../src\"]\n"))
(("^(installed_lib_dir1 = ).*" _ prefix)
(string-append prefix "\"" out "/lib\"\n"))
(("^installed_lib_dir2 = .*") "")
(("^ +link_args\\.append\\(\"-Wl,-rpath,\" \\+ installed_lib_dir2\\)\n")
"")))))
;; Fix the tests so they run in out-of-source builds.
;;
;; TODO: Add support for examples/basic/batch/single_obj_MPIparallel,
;; by adding openmpi to native-inputs and adjusting the example's
;; BB_EXE parameter.
(add-after 'fix-sources-for-build 'fix-sources-for-tests
(lambda _ (lambda _
(substitute* "examples/CMakeLists.txt" (substitute* "examples/CMakeLists.txt"
;; This test passes only sometimes. ;; This test passes only sometimes.
;; See https://github.com/bbopt/nomad/issues/72. ;; See https://github.com/bbopt/nomad/issues/72.
(("^ +add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/advanced/library/PSDMads\\)\n") (("^ +add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/advanced/library/PSDMads\\)\n")
"") ""))
;; examples/basic/batch/example3 is accidentally omitted. (make-file-writable
(("^(add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/basic/batch/example)2(\\)\n)" "examples/advanced/library/exampleSuggestAndObserve/cache0.txt")
_ prefix suffix) ;; Fix the tests so they run in out-of-source builds.
(string-append prefix "2" suffix
prefix "3" suffix))
;; The generated runExampleTest.sh script runs the test as part
;; of a pipeline and incorrectly (because pipefail is unset)
;; relies on the value of the exit status immediately after the
;; pipeline.
;; (The patch-shebangs phase runs later than this one, so no
;; need to update the path to bash here.)
(("#!/bin/bash") "#!/bin/bash\nset -o pipefail"))
(substitute* (substitute*
(map (lambda (d) (string-append "examples/" d "/CMakeLists.txt")) '("examples/basic/library/COCO/CMakeLists.txt"
(append "examples/basic/library/example1/CMakeLists.txt"
(map (lambda (d) (string-append "basic/library/" d)) "examples/basic/library/example2/CMakeLists.txt"
'("example1" "example2" "example3" "examples/basic/library/example3/CMakeLists.txt"
"single_obj_parallel")) "examples/basic/library/example4/CMakeLists.txt"
(map (lambda (d) (string-append "advanced/library/" d)) "examples/basic/library/single_obj_parallel/CMakeLists.txt"
'("FixedVariable" "NMonly" "PSDMads" "Restart" "examples/advanced/library/FixedVariable/CMakeLists.txt"
"c_api/example1" "c_api/example2" "examples/advanced/library/NMonly/CMakeLists.txt"
"exampleSuggestAndObserve")))) "examples/advanced/library/PSDMads/CMakeLists.txt"
"examples/advanced/library/Restart/CMakeLists.txt"
"examples/advanced/library/Restart_VNS/CMakeLists.txt"
"examples/advanced/library/c_api/example1/CMakeLists.txt"
"examples/advanced/library/c_api/example2/CMakeLists.txt"
"examples/advanced/library/exampleSuggestAndObserve/CMakeLists.txt")
;; The runExampleTest.sh script is run with WORKING_DIRECTORY ;; The runExampleTest.sh script is run with WORKING_DIRECTORY
;; set to CMAKE_CURRENT_SOURCE_DIR. ;; set to CMAKE_CURRENT_SOURCE_DIR.
;; Other scripts invoked by that script (for example ;; Other scripts invoked by that script (for example
@ -2529,22 +2477,11 @@ interfaces.")
(("(COMMAND \\$\\{CMAKE_BINARY_DIR\\}/examples/runExampleTest\\.sh )\\.(/.*)" (("(COMMAND \\$\\{CMAKE_BINARY_DIR\\}/examples/runExampleTest\\.sh )\\.(/.*)"
_ command test) _ command test)
(string-append command "${CMAKE_CURRENT_BINARY_DIR}" test))) (string-append command "${CMAKE_CURRENT_BINARY_DIR}" test)))
;; The examples/basic/batch/example3 executable is already named
;; bb3.exe.
(substitute* "examples/basic/batch/single_obj_parallel/CMakeLists.txt"
(("bb3.exe") "bb_parallel.exe"))
;; (Unrelated to support for out-of-source testing.)
(make-file-writable
"examples/advanced/library/exampleSuggestAndObserve/cache0.txt")
(let ((builddir (string-append (getcwd) "/../build"))) (let ((builddir (string-append (getcwd) "/../build")))
(let ((dir "examples/advanced/library/FixedVariable")) (let ((dir "examples/advanced/library/FixedVariable"))
(substitute* (string-append dir "/fixedVariable.cpp") (substitute* (string-append dir "/fixedVariable.cpp")
(("^( +std::string sExe = ).*" _ prefix) (("^( +std::string sExe = ).*" _ prefix)
(string-append prefix "\"" builddir "/" dir "/ufl.exe" "\";\n")))) (string-append prefix "\"" builddir "/" dir "/ufl.exe" "\";\n"))))
;; The BB_EXE and SURROGATE_EXE paths are interpreted relative ;; The BB_EXE and SURROGATE_EXE paths are interpreted relative
;; to the configuration file provided to NOMAD. ;; to the configuration file provided to NOMAD.
;; However, the configuration files are all in the source tree ;; However, the configuration files are all in the source tree
@ -2564,30 +2501,38 @@ interfaces.")
builddir "/" dir "/")))))) builddir "/" dir "/"))))))
(for-each (for-each
(lambda (dir) (lambda (dir)
(let ((dir (string-append "examples/" dir)))
(substitute* (string-append dir "/CMakeLists.txt") (substitute* (string-append dir "/CMakeLists.txt")
;; The install phase has not yet run. ;; The install phase has not yet run.
(("COMMAND \\$\\{CMAKE_INSTALL_PREFIX\\}/bin/nomad ") (("(COMMAND.*)\\$\\{CMAKE_INSTALL_PREFIX\\}/bin/nomad\\b"
"COMMAND ${CMAKE_BINARY_DIR}/src/nomad ")) _ prefix)
(fix-exe-path dir) (string-append prefix "${CMAKE_BINARY_DIR}/src/nomad")))
(if (equal? dir "examples/basic/batch/single_obj_MPIparallel")
(substitute* (string-append dir "/param.txt")
(("^BB_EXE +'\\$.*mpirun \\$-np \\$4 ")
(string-append "BB_EXE '$" (which "mpirun") " $"
builddir "/" dir "/")))
(fix-exe-path dir))
(when (equal? dir "examples/basic/batch/surrogate_sort") (when (equal? dir "examples/basic/batch/surrogate_sort")
(fix-exe-path dir "param.txt" "SURROGATE_EXE")))) (fix-exe-path dir "param.txt" "SURROGATE_EXE"))
(append (map (lambda (d) (string-append "basic/batch/" d)) (when (equal? dir "examples/advanced/batch/FixedVariable")
'("example1" "example2" "example3" (fix-exe-path dir "param1.txt")
"single_obj" (fix-exe-path dir "param2.txt")
"single_obj_parallel" (fix-exe-path dir "param3.txt")
;; "single_obj_MPIparallel" (fix-exe-path dir "param10.txt")))
"surrogate_sort")) '("examples/basic/batch/coco_bbob-constrained"
'("advanced/batch/LHonly"))) "examples/basic/batch/example1"
"examples/basic/batch/example2"
(let ((dir "examples/advanced/batch/FixedVariable")) "examples/basic/batch/example3"
(substitute* (string-append dir "/runFixed.sh") "examples/basic/batch/multi_obj"
;; Hardcoded path to NOMAD executable. "examples/basic/batch/multi_obj2"
(("^\\.\\./\\.\\./\\.\\./\\.\\./bin/nomad ") "examples/basic/batch/single_obj"
(string-append builddir "/src/nomad "))) "examples/basic/batch/single_obj_MPIparallel"
(for-each "examples/basic/batch/single_obj_parallel"
(lambda (f) (fix-exe-path dir f)) "examples/basic/batch/surrogate_sort"
'("param1.txt" "param2.txt" "param3.txt" "param10.txt")))))))))) "examples/advanced/batch/FixedVariable"
"examples/advanced/batch/LHonly"))))))
(add-before 'configure 'mpi-setup
#$%openmpi-setup))))
(home-page "https://www.gerad.ca/nomad/") (home-page "https://www.gerad.ca/nomad/")
(synopsis "Nonlinear optimization by mesh-adaptive direct search") (synopsis "Nonlinear optimization by mesh-adaptive direct search")
(description (description