Add package for serenity and its scine wrapper (#35072)

This commit is contained in:
Sebastian Ehlert 2023-01-26 10:00:34 +01:00 committed by GitHub
parent 918bb63c3a
commit f686a90779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 238 additions and 0 deletions

View file

@ -0,0 +1,72 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack.package import *
class ScineSerenity(CMakePackage):
"""Wrapper around Serenity to make it compatible with Scine"""
homepage = "https://scine.ethz.ch"
url = "https://github.com/qcscine/serenity_wrapper/archive/refs/tags/1.0.1.tar.gz"
git = "https://github.com/qcscine/serenity_wrapper"
version("master", branch="master")
version("1.0.1", "e2e5cc265a68ccab05f1bc934b957ca07c4f1c6004e662684023da451da69299")
resource(
name="dev",
url="https://github.com/qcscine/development-utils/archive/refs/tags/5.0.1.tar.gz",
sha256="089ca500fc191e04a968ea166d2fe80178b227bc2e6d3926523fa2eee5f6492d",
placement="_dev",
)
variant("python", default=False, description="Build Python extension module")
depends_on("boost+system+filesystem+program_options cxxstd=17 @1.65.0:")
depends_on("python@3.6:", when="+python", type=("build", "run"))
depends_on("py-pip", when="+python", type="build")
depends_on("scine-core")
depends_on("scine-utilities")
depends_on("scine-utilities+python", when="+python", type=("build", "run"))
depends_on("serenity")
extends("python", when="+python")
def patch(self):
os.rmdir("dev")
os.rename("_dev", "dev")
filter_file(
# Serenity does not install any config or targets file...
"find_package(serenity QUIET)",
"find_library(SERENITY_LIBRARY serenity REQUIRED)\n"
"add_library(serenity INTERFACE IMPORTED)\n"
"target_link_libraries(serenity INTERFACE ${SERENITY_LIBRARY})\n"
"target_include_directories(serenity INTERFACE ${SERENITY_INCLUDE_DIR})\n"
"find_package(OpenMP REQUIRED)\n"
"target_compile_options(serenity INTERFACE ${OpenMP_CXX_FLAGS})\n",
"CMakeLists.txt",
string=True,
)
def cmake_args(self):
args = [
self.define("SCINE_BUILD_TESTS", self.run_tests),
self.define_from_variant("SCINE_BUILD_PYTHON_BINDINGS", "python"),
self.define("SCINE_MARCH", ""),
self.define("serenity_DIR", self.spec["serenity"].prefix.lib.cmake.serenity),
self.define("SERENITY_INCLUDE_DIR", self.spec["serenity"].prefix.include.serenity),
self.define("BOOST_ROOT", self.spec["boost"].prefix),
self.define("BOOST_LIBRARY_DIR", self.spec["boost"].libs.directories[0]),
self.define("BOOST_INCLUDE_DIR", self.spec["boost"].headers.directories[0]),
self.define("BOOST_NO_SYSTEM_PATHS", True),
self.define("Boost_NO_BOOST_CMAKE", True),
]
if "+python" in self.spec:
args.append(self.define("PYTHON_EXECUTABLE", self.spec["python"].command.path))
return args

View file

@ -0,0 +1,25 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class SerenityLibint(CMakePackage):
"""Serenity fork of libint, which is difficult to reproduce from libint itself"""
homepage = "https://thclab.uni-muenster.de/serenity/libint"
url = "https://thclab.uni-muenster.de/serenity/libint/-/raw/e3eb756c/libint-2.7.0-beta.6.tgz"
version("2.7.0-beta.6", "53af60c7be74374b2a2d893b3d2d37fa6a3078a72d98067bf71ba4ede4e807df")
depends_on("boost")
depends_on("eigen@3:") # Probably overdepending?
depends_on("gmp+cxx")
def cmake_args(self):
args = [
self.define("BUILD_SHARED_LIBS", True),
]
return args

View file

@ -0,0 +1,141 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class Serenity(CMakePackage):
"""Subsystem focused quantum chemistry code Serenity"""
homepage = "https://www.uni-muenster.de/Chemie.oc/neugebauer/softwareAKN.html"
url = "https://github.com/qcserenity/serenity/archive/refs/tags/1.4.0.tar.gz"
git = "https://github.com/qcserenity/serenity.git"
version("master", branch="master")
version("1.4.0", "c7a87fc8e6f8ca21685a27e08d09d49824d9a1e9947fc6abb40d20fbba0cc6e8")
variant("blas", default=True, description="Use BLAS library with Eigen")
variant("lapack", default=True, description="Use Lapack library with Eigen")
variant("python", default=False, description="Build Python bindings")
depends_on("blas", when="+blas")
depends_on("cmake@3.12:", type="build")
depends_on("boost")
depends_on("eigen@3:")
depends_on("googletest@1.8.1:", type="test")
depends_on("hdf5@1.10.1:")
depends_on("lapack", when="+lapack")
depends_on("libecpint")
depends_on("libxc@5.0.0")
depends_on("pkgconfig", type="build")
depends_on("python@3.6:", when="+python", type=("build", "run"))
depends_on("py-pip", when="+python", type="build")
depends_on("py-pybind11", when="+python", type="build")
depends_on("serenity-libint")
depends_on("xcfun")
extends("python", when="+python")
def patch(self):
filter_file(
"include(CMakeParseArguments)",
'message(FATAL_ERROR "Tried to download a dependency")',
"cmake/DownloadProject.cmake",
string=True,
)
if self.run_tests:
filter_file(
"find_package(GTest 1.8.1 QUIET)",
"find_package(GTest REQUIRED)",
"cmake/ImportGTest.cmake",
string=True,
)
filter_file(
"find_package(GMock 1.8.1 QUIET)",
"return()",
"cmake/ImportGTest.cmake",
string=True,
)
filter_file(
"function(import_libecpint)",
"function(import_libecpint)\n"
"find_package(ecpint CONFIG REQUIRED)\n"
"add_library(ecpint INTERFACE IMPORTED)\n"
"target_link_libraries(ecpint INTERFACE ECPINT::ecpint)\n",
"cmake/ImportLibecpint.cmake",
string=True,
)
filter_file(
"function(import_libint)",
"function(import_libint)\n"
"find_package(Libint2 CONFIG REQUIRED)\n"
"add_library(libint2-static INTERFACE IMPORTED)\n"
"target_link_libraries(libint2-static INTERFACE Libint2::libint2)\n",
"cmake/ImportLibint.cmake",
string=True,
)
filter_file(
"function(import_libxc)",
"function(import_libxc)\n"
"find_package(PkgConfig QUIET)\n"
"pkg_check_modules(pc_libxc libxc)\n"
"if(pc_libxc_FOUND)\n"
"add_library(xc INTERFACE IMPORTED)\n"
"target_link_libraries(xc INTERFACE ${pc_libxc_LINK_LIBRARIES})\n"
"target_include_directories(xc INTERFACE ${pc_libxc_INCLUDE_DIRS})\n"
"endif()",
"cmake/ImportLibxc.cmake",
string=True,
)
filter_file(
"function(import_pybind11)",
"function(import_pybind11)\nfind_package(pybind11 REQUIRED)",
"cmake/ImportPybind11.cmake",
string=True,
)
filter_file(
"function(import_xcfun)",
"function(import_xcfun)\n"
"find_package(XCFun CONFIG REQUIRED)\n"
"add_library(xcfun INTERFACE IMPORTED)\n"
"target_link_libraries(xcfun INTERFACE XCFun::xcfun)\n",
"cmake/ImportXCFun.cmake",
string=True,
)
def cmake_args(self):
args = [
self.define("SERENITY_BUILD_TESTS", self.run_tests),
self.define_from_variant("SERENITY_BUILD_PYTHON_BINDINGS", "python"),
self.define("SERENITY_MARCH", ""),
self.define("SERENITY_PREFER_XCFUN", False),
self.define("SERENITY_USE_XCFUN", True),
self.define("SERENITY_USE_LIBXC", True),
self.define(
"SERENITY_USE_INTEL_MKL", self.spec["lapack"].libs.names[0].startswith("mkl")
),
self.define_from_variant("SERENITY_USE_LAPACK", "lapack"),
self.define_from_variant("SERENITY_USE_BLAS", "blas"),
self.define("SERENITY_USAGE_FROM_SOURCE", False),
self.define("Libint2_DIR", self.spec["serenity-libint"].prefix.lib.cmake.libint2),
self.define("XCFun_DIR", self.spec["xcfun"].prefix.share.XCFun),
self.define("BUILD_SHARED_LIBS", True),
self.define("BOOST_ROOT", self.spec["boost"].prefix),
self.define("BOOST_LIBRARY_DIR", self.spec["boost"].libs.directories[0]),
self.define("BOOST_INCLUDE_DIR", self.spec["boost"].headers.directories[0]),
self.define("BOOST_NO_SYSTEM_PATHS", True),
self.define("Boost_NO_BOOST_CMAKE", True),
]
if "+python" in self.spec:
args.append(self.define("PYTHON_EXECUTABLE", self.spec["python"].command.path))
return args