diff --git a/repos/spack_repo/builtin/packages/meshioplusplus/package.py b/repos/spack_repo/builtin/packages/meshioplusplus/package.py new file mode 100644 index 00000000000..de661a7024b --- /dev/null +++ b/repos/spack_repo/builtin/packages/meshioplusplus/package.py @@ -0,0 +1,104 @@ +# Copyright Spack Project Developers. See COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack_repo.builtin.build_systems.cmake import CMakePackage + +from spack.package import * + + +class Meshioplusplus(CMakePackage): + """meshio++: a C++20 mesh I/O core with an installable C API + (``libmeshioplusplus``, a pure-C99 header with pkg-config and + ``find_package`` support) and an optional modern OO Fortran 2008 interface + for HPC codes. Reads and writes ~40 unstructured mesh formats. + + This package builds the standalone C / C++ / Fortran library. For the + Python bindings (the pybind11 ``_core`` extension) use ``py-meshioplusplus``. + """ + + homepage = "https://github.com/loumalouomega/meshioplusplus" + url = "https://github.com/loumalouomega/meshioplusplus/archive/refs/tags/v6.6.1.tar.gz" + git = "https://github.com/loumalouomega/meshioplusplus.git" + + maintainers("loumalouomega") + + license("MIT", checked_by="loumalouomega") + + version("main", branch="main") + version("6.6.1", sha256="327c1b146fefa3eb19404e2b422b5cf789fe81b8f402fea9694124d50b13e88b") + version("6.6.0", sha256="a585a7b932a9a893b17710f68ed64a04b492d12abfe74c5744812fb44599cbae") + version("6.5.0", sha256="f0ebdb7a547097ae338b2295eaa2cb08fe728a7d32c408f4109511ded3196779") + version("6.4.0", sha256="d969bb081ac5bb9b43ce0fa32d3c6a5a8fc53a9f4ad086b03d7ebb40368a01fb") + version("6.3.0", sha256="ead9fd2264ba809903c91347b7cbd1e526ac78373b2935590c967cad20aacf59") + # The installable C API and Fortran interface were introduced in 6.2.0. + # Earlier C++ releases only ship the Python extension, so with Python off a + # CMake build of them installs nothing -- see py-meshioplusplus for those. + version("6.2.0", sha256="275c1a938845a416040b1517fb8f9c1c008e86ad888b432d0852eba0fac83126") + + variant( + "fortran", + default=False, + description="Build the OO Fortran 2008 interface (implies the C API)", + ) + variant( + "hdf5", default=True, description="C++ HDF5-backed formats (CGNS, HMF, H5M, MED, XDMF-HDF)" + ) + variant("netcdf", default=True, description="C++ netCDF-backed format (Exodus)") + variant("zlib", default=True, description="C++ VTU zlib compression path") + variant( + "parallel", + default="auto", + values=("auto", "seq", "stl", "openmp", "tbb"), + multi=False, + description="Parallel backend for meshioplusplus::parallel_for", + ) + variant( + "mesh_backend", + default="native", + values=("meshio", "native", "kratos"), + multi=False, + description="In-memory mesh backend for the standalone C++ build", + ) + + depends_on("c", type="build") + depends_on("cxx", type="build") + depends_on("fortran", type="build", when="+fortran") + depends_on("cmake@3.15:", type="build") + + depends_on("hdf5", when="+hdf5") + # A parallel HDF5 needs mpi.h even for serial use of the C API. + depends_on("mpi", when="+hdf5 ^hdf5+mpi") + depends_on("netcdf-c", when="+netcdf") + depends_on("zlib-api", when="+zlib") + # The TBB and (on libstdc++) the STL parallel backends need TBB. + depends_on("tbb", when="parallel=tbb") + depends_on("tbb", when="parallel=stl") + + # meshio++ requires a C++20 toolchain. + conflicts("%gcc@:9", msg="meshio++ needs GCC >= 10 for C++20") + + def cmake_args(self): + spec = self.spec + args = [ + # Python is packaged separately as py-meshioplusplus; here the C API + # is the installable artifact, so keep it on unconditionally. + self.define("MESHIOPLUSPLUS_BUILD_PYTHON", False), + self.define("MESHIOPLUSPLUS_BUILD_C_API", True), + self.define_from_variant("MESHIOPLUSPLUS_BUILD_FORTRAN", "fortran"), + self.define_from_variant("MESHIOPLUSPLUS_WITH_HDF5", "hdf5"), + self.define_from_variant("MESHIOPLUSPLUS_WITH_NETCDF", "netcdf"), + self.define_from_variant("MESHIOPLUSPLUS_WITH_ZLIB", "zlib"), + # Eigen is a vendored git submodule (a MED-transpose optimization + # only); the release tarball omits it, so use the plain-loop fallback. + self.define("MESHIOPLUSPLUS_WITH_EIGEN", False), + self.define( + "MESHIOPLUSPLUS_PARALLEL_BACKEND", + spec.variants["parallel"].value.upper(), + ), + self.define( + "MESHIOPLUSPLUS_MESH_BACKEND", + spec.variants["mesh_backend"].value.upper(), + ), + ] + return args diff --git a/repos/spack_repo/builtin/packages/py_meshioplusplus/package.py b/repos/spack_repo/builtin/packages/py_meshioplusplus/package.py new file mode 100644 index 00000000000..0f5f132aa1b --- /dev/null +++ b/repos/spack_repo/builtin/packages/py_meshioplusplus/package.py @@ -0,0 +1,73 @@ +# Copyright Spack Project Developers. See COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack_repo.builtin.build_systems.python import PythonPackage + +from spack.package import * + + +class PyMeshioplusplus(PythonPackage): + """meshio++: I/O for many mesh formats. A C++20 core (pybind11) with a + pure-Python fallback for every format, so behavior and file compatibility + are identical whether or not the native libraries are present.""" + + homepage = "https://github.com/loumalouomega/meshioplusplus" + # 6.0.0 has no PyPI sdist, so build every version from the GitHub archive + # (scikit-build-core builds fine from the source tree) for a uniform source. + url = "https://github.com/loumalouomega/meshioplusplus/archive/refs/tags/v6.6.1.tar.gz" + git = "https://github.com/loumalouomega/meshioplusplus.git" + + maintainers("loumalouomega") + + license("MIT", checked_by="loumalouomega") + + version("main", branch="main") + version("6.6.1", sha256="327c1b146fefa3eb19404e2b422b5cf789fe81b8f402fea9694124d50b13e88b") + version("6.6.0", sha256="a585a7b932a9a893b17710f68ed64a04b492d12abfe74c5744812fb44599cbae") + version("6.5.0", sha256="f0ebdb7a547097ae338b2295eaa2cb08fe728a7d32c408f4109511ded3196779") + version("6.4.0", sha256="d969bb081ac5bb9b43ce0fa32d3c6a5a8fc53a9f4ad086b03d7ebb40368a01fb") + version("6.3.0", sha256="ead9fd2264ba809903c91347b7cbd1e526ac78373b2935590c967cad20aacf59") + version("6.2.0", sha256="275c1a938845a416040b1517fb8f9c1c008e86ad888b432d0852eba0fac83126") + version("6.1.0", sha256="0061d9b3ff20b65f6bb66dc4787b4c8f5c9f3abc9567b0b9e60fab28a8774afa") + version("6.0.0", sha256="c5edd1c3f961a6282f08a76205e060ed3cb985401381313beb02788bc537ba94") + + variant("hdf5", default=True, description="C++ HDF5-backed formats and the h5py fallback") + variant( + "netcdf", + default=True, + description="C++ netCDF-backed format (Exodus) and the netCDF4 fallback", + ) + variant("zlib", default=True, description="C++ VTU zlib compression path") + + depends_on("c", type="build") + depends_on("cxx", type="build") + depends_on("cmake@3.15:", type="build") + depends_on("py-scikit-build-core@0.8:", type="build") + depends_on("py-pybind11@2.11:", type="build") + + depends_on("python@3.8:", type=("build", "link", "run")) + depends_on("py-numpy@1.20:", type=("build", "run")) + depends_on("py-rich", type="run") + + depends_on("hdf5", when="+hdf5") + # Some HDF5 formats (e.g. MED) always run the Python implementation. + depends_on("py-h5py", when="+hdf5", type="run") + depends_on("netcdf-c", when="+netcdf") + depends_on("py-netcdf4", when="+netcdf", type="run") + depends_on("zlib-api", when="+zlib") + + # meshio++ requires a C++20 toolchain for the native core. + conflicts("%gcc@:9", msg="meshio++ needs GCC >= 10 for C++20") + + def config_settings(self, spec, prefix): + # scikit-build-core forwards these to the CMake configure. The pybind11 + # extension requires the MESHIO mesh backend, which is the CMake default. + def onoff(variant): + return "ON" if spec.satisfies(variant) else "OFF" + + return { + "cmake.define.MESHIOPLUSPLUS_WITH_HDF5": onoff("+hdf5"), + "cmake.define.MESHIOPLUSPLUS_WITH_NETCDF": onoff("+netcdf"), + "cmake.define.MESHIOPLUSPLUS_WITH_ZLIB": onoff("+zlib"), + }