|
| 1 | +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other |
| 2 | +# Spack Project Developers. See the top-level COPYRIGHT file for details. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: (Apache-2.0 OR MIT) |
| 5 | + |
| 6 | +from spack_repo.builtin.build_systems.cmake import CMakePackage, generator |
| 7 | + |
| 8 | +from spack.package import * |
| 9 | + |
| 10 | + |
| 11 | +class Ioda(CMakePackage): |
| 12 | + """Interface for Observation Data Access""" |
| 13 | + |
| 14 | + homepage = "https://github.com/JCSDA/ioda" |
| 15 | + git = "https://github.com/JCSDA/ioda.git" |
| 16 | + |
| 17 | + maintainers("climbfuji") |
| 18 | + |
| 19 | + version("develop", branch="develop", no_cache=True) |
| 20 | + version("2.9.0.20250826", commit="6e76616001067384f7d0ca4341ad78e81527af8b") |
| 21 | + |
| 22 | + patch("ioda_cmake_import.patch", when="@2.9.0.20250826") |
| 23 | + |
| 24 | + variant("doc", default=False, description="Build IODA documentation") |
| 25 | + # Let's always assume IODA_BUILD_LANGUAGE_FORTRAN=on. |
| 26 | + # variant('fortran', default=True, description='Build the ioda Fortran interface') |
| 27 | + variant("odc", default=True, description="Build ODC bindings") |
| 28 | + # ioda has no explicit OpenMP calls, but header files from Eigen and oops do use openmp. |
| 29 | + variant("openmp", default=True, description="Build with OpenMP support") |
| 30 | + # Let's always BUILD_PYTHON_BINDINGS. |
| 31 | + # variant('python', default=True, description='Build the ioda Python interface') |
| 32 | + |
| 33 | + generator("make") |
| 34 | + |
| 35 | + # Project doesn't list "c" as a dependency in CMakeLists.txt, but cmake step fails w/o it |
| 36 | + depends_on("c", type=("build")) |
| 37 | + depends_on("cxx", type=("build")) |
| 38 | + depends_on("fortran", type=("build")) |
| 39 | + |
| 40 | + depends_on("boost@1.64.0:") |
| 41 | + depends_on("bufr") |
| 42 | + depends_on("bufr@12.0.1:", when="@2.9:") |
| 43 | + depends_on("bufr-query@0.0.4:", when="@2.9:") |
| 44 | + depends_on("cmake", type=("build")) |
| 45 | + depends_on("cmake@3.14:", type=("build"), when="@2.9:") |
| 46 | + depends_on("ecbuild", type=("build")) |
| 47 | + depends_on("ecbuild@3.3.2:", type=("build"), when="@2.9:") |
| 48 | + depends_on("eckit") |
| 49 | + depends_on("eckit@1.23.0:", when="@2.9:") |
| 50 | + depends_on("eigen") |
| 51 | + depends_on("fckit") |
| 52 | + depends_on("fckit@0.10.1:", when="@2.9:") |
| 53 | + depends_on("gsl-lite") |
| 54 | + depends_on("hdf5@1.12.0: +mpi") |
| 55 | + depends_on("hdf5@1.14.0: +mpi", when="@2.9:") |
| 56 | + depends_on("ioda-data", type=("build", "test")) |
| 57 | + depends_on("ioda-data@2.9.0.20250805", type=("build", "test"), when="@2.9:") |
| 58 | + depends_on("jedi-cmake", type=("build")) |
| 59 | + depends_on("llvm-openmp", when="+openmp %apple-clang", type=("build", "link", "run")) |
| 60 | + depends_on("mpi") |
| 61 | + depends_on("nccmp", type=("build", "test")) |
| 62 | + depends_on("netcdf-cxx", when="@2.9:") |
| 63 | + depends_on("odc", when="+odc") |
| 64 | + depends_on("odc@1.4.6:", when="@2.9: +odc") |
| 65 | + depends_on("oops+openmp", when="+openmp") |
| 66 | + depends_on("oops~openmp", when="~openmp") |
| 67 | + depends_on("oops@1.10", when="@2.9:") |
| 68 | + depends_on("python") |
| 69 | + depends_on("python@3.9:3.11", when="@2.9:") |
| 70 | + depends_on("py-pybind11") |
| 71 | + depends_on("py-pycodestyle", type=("build", "test")) |
| 72 | + depends_on("py-netcdf4", type=("build", "test")) |
| 73 | + depends_on("udunits") |
| 74 | + depends_on("udunits@2.2.0:", when="@2.9:") |
| 75 | + |
| 76 | + def cmake_args(self): |
| 77 | + res = [ |
| 78 | + self.define("BUILD_TESTING", self.run_tests), |
| 79 | + self.define_from_variant("ENABLE_IODA_DOC", "doc"), |
| 80 | + ] |
| 81 | + return res |
| 82 | + |
| 83 | + def setup_build_environment(self, env: EnvironmentModifications) -> None: |
| 84 | + """This needs to be set at build time, not at test time, |
| 85 | + to prevent IODA from downloading test data from S4""" |
| 86 | + env.set("IODA_TESTFILES", self.spec["ioda-data"].prefix) |
| 87 | + |
| 88 | + def check(self): |
| 89 | + skipped_tests = None |
| 90 | + with when("@2.9.0.20250826"): |
| 91 | + # No time to deal with the bufr Python dependency |
| 92 | + skipped_tests = [ |
| 93 | + "test_ioda_bufr_python_encoder", |
| 94 | + "test_ioda_bufr_python_parallel", |
| 95 | + ] |
| 96 | + |
| 97 | + ctest = Executable(self.spec["cmake"].prefix.bin.ctest) |
| 98 | + with working_dir(self.build_directory): |
| 99 | + if skipped_tests: |
| 100 | + ctest("--timeout", "120", "-E", "|".join(skipped_tests)) |
| 101 | + else: |
| 102 | + ctest("--timeout", "120") |
| 103 | + |
| 104 | + @run_after("install") |
| 105 | + def fix_ioda_yaml_root_path(self): |
| 106 | + with when("@2.9.0.20250826"): |
| 107 | + filter_file( |
| 108 | + join_path(self.build_directory, "share/test/testinput/"), |
| 109 | + join_path(self.prefix, "share/ioda/yaml"), |
| 110 | + join_path(self.prefix, "lib64/cmake/ioda/ioda-import.cmake"), |
| 111 | + ) |
0 commit comments