updates to conduit to add hostcfg and use cmake base (#22233)
This commit is contained in:
parent
4f1a76a0d1
commit
4df1f62fd3
@ -27,7 +27,7 @@ def cmake_cache_entry(name, value, vtype=None):
|
|||||||
return 'set({0} "{1}" CACHE {2} "")\n\n'.format(name, value, vtype)
|
return 'set({0} "{1}" CACHE {2} "")\n\n'.format(name, value, vtype)
|
||||||
|
|
||||||
|
|
||||||
class Conduit(Package):
|
class Conduit(CMakePackage):
|
||||||
"""Conduit is an open source project from Lawrence Livermore National
|
"""Conduit is an open source project from Lawrence Livermore National
|
||||||
Laboratory that provides an intuitive model for describing hierarchical
|
Laboratory that provides an intuitive model for describing hierarchical
|
||||||
scientific data in C++, C, Fortran, and Python. It is used for data
|
scientific data in C++, C, Fortran, and Python. It is used for data
|
||||||
@ -90,8 +90,8 @@ class Conduit(Package):
|
|||||||
#######################
|
#######################
|
||||||
# CMake
|
# CMake
|
||||||
#######################
|
#######################
|
||||||
# cmake 3.8.2 or newer
|
# cmake 3.14.1 or newer
|
||||||
depends_on("cmake@3.8.2:", type='build')
|
depends_on("cmake@3.14.1:", type='build')
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Python
|
# Python
|
||||||
@ -108,7 +108,7 @@ class Conduit(Package):
|
|||||||
###############
|
###############
|
||||||
# HDF5
|
# HDF5
|
||||||
###############
|
###############
|
||||||
# TODO: cxx variant is disabled due to build issue Cyrus
|
# Note: cxx variant is disabled due to build issue Cyrus
|
||||||
# experienced on BGQ. When on, the static build tries
|
# experienced on BGQ. When on, the static build tries
|
||||||
# to link against shared libs.
|
# to link against shared libs.
|
||||||
#
|
#
|
||||||
@ -137,7 +137,10 @@ class Conduit(Package):
|
|||||||
#######################
|
#######################
|
||||||
# ZFP
|
# ZFP
|
||||||
#######################
|
#######################
|
||||||
depends_on("zfp", when="+zfp")
|
depends_on("zfp bsws=8", when="+zfp")
|
||||||
|
|
||||||
|
# hdf5 zfp plugin when both hdf5 and zfp are on
|
||||||
|
depends_on("h5z-zfp~fortran", when="+hdf5+zfp")
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# MPI
|
# MPI
|
||||||
@ -155,8 +158,10 @@ class Conduit(Package):
|
|||||||
# Cmake will support fj compiler and this patch will be removed
|
# Cmake will support fj compiler and this patch will be removed
|
||||||
patch('fj_flags.patch', when='%fj')
|
patch('fj_flags.patch', when='%fj')
|
||||||
|
|
||||||
|
###################################
|
||||||
# build phases used by this package
|
# build phases used by this package
|
||||||
phases = ["configure", "build", "install"]
|
###################################
|
||||||
|
phases = ['hostconfig', 'cmake', 'build', 'install']
|
||||||
|
|
||||||
def flag_handler(self, name, flags):
|
def flag_handler(self, name, flags):
|
||||||
if name in ('cflags', 'cxxflags', 'fflags'):
|
if name in ('cflags', 'cxxflags', 'fflags'):
|
||||||
@ -184,42 +189,16 @@ def url_for_version(self, version):
|
|||||||
return "https://github.com/LLNL/conduit/releases/download/v{0}/conduit-v{1}-src-with-blt.tar.gz".format(v, v)
|
return "https://github.com/LLNL/conduit/releases/download/v{0}/conduit-v{1}-src-with-blt.tar.gz".format(v, v)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def configure(self, spec, prefix):
|
####################################################################
|
||||||
"""
|
# Note: cmake, build, and install stages are handled by CMakePackage
|
||||||
Configure Conduit.
|
####################################################################
|
||||||
"""
|
|
||||||
with working_dir('spack-build', create=True):
|
|
||||||
py_site_pkgs_dir = None
|
|
||||||
if "+python" in spec:
|
|
||||||
py_site_pkgs_dir = site_packages_dir
|
|
||||||
|
|
||||||
host_cfg_fname = self.create_host_config(spec,
|
# provide cmake args (pass host config as cmake cache file)
|
||||||
prefix,
|
def cmake_args(self):
|
||||||
py_site_pkgs_dir)
|
host_config = self._get_host_config_path(self.spec)
|
||||||
# save this filename for
|
options = []
|
||||||
# other package recipe steps to access
|
options.extend(['-C', host_config, "../spack-src/src/"])
|
||||||
self.host_cfg_fname = host_cfg_fname
|
return options
|
||||||
cmake_args = []
|
|
||||||
# if we have a static build, we need to avoid any of
|
|
||||||
# spack's default cmake settings related to rpaths
|
|
||||||
# (see: https://github.com/spack/spack/issues/2658)
|
|
||||||
if "+shared" in spec:
|
|
||||||
cmake_args.extend(std_cmake_args)
|
|
||||||
else:
|
|
||||||
for arg in std_cmake_args:
|
|
||||||
if arg.count("RPATH") == 0:
|
|
||||||
cmake_args.append(arg)
|
|
||||||
cmake_args.extend(["-C", host_cfg_fname, "../src"])
|
|
||||||
print("Configuring Conduit...")
|
|
||||||
cmake(*cmake_args)
|
|
||||||
|
|
||||||
def build(self, spec, prefix):
|
|
||||||
"""
|
|
||||||
Build Conduit.
|
|
||||||
"""
|
|
||||||
with working_dir('spack-build'):
|
|
||||||
print("Building Conduit...")
|
|
||||||
make()
|
|
||||||
|
|
||||||
@run_after('build')
|
@run_after('build')
|
||||||
@on_package_attributes(run_tests=True)
|
@on_package_attributes(run_tests=True)
|
||||||
@ -228,16 +207,6 @@ def build_test(self):
|
|||||||
print("Running Conduit Unit Tests...")
|
print("Running Conduit Unit Tests...")
|
||||||
make("test")
|
make("test")
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
|
||||||
"""
|
|
||||||
Install Conduit.
|
|
||||||
"""
|
|
||||||
with working_dir('spack-build'):
|
|
||||||
make("install")
|
|
||||||
# install copy of host config for provenance
|
|
||||||
print("Installing Conduit CMake Host Config File...")
|
|
||||||
install(self.host_cfg_fname, prefix)
|
|
||||||
|
|
||||||
@run_after('install')
|
@run_after('install')
|
||||||
@on_package_attributes(run_tests=True)
|
@on_package_attributes(run_tests=True)
|
||||||
def check_install(self):
|
def check_install(self):
|
||||||
@ -275,24 +244,30 @@ def check_install(self):
|
|||||||
example = Executable('./conduit_example')
|
example = Executable('./conduit_example')
|
||||||
example()
|
example()
|
||||||
|
|
||||||
def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
def _get_host_config_path(self, spec):
|
||||||
|
sys_type = spec.architecture
|
||||||
|
# if on llnl systems, we can use the SYS_TYPE
|
||||||
|
if "SYS_TYPE" in env:
|
||||||
|
sys_type = env["SYS_TYPE"]
|
||||||
|
host_config_path = "{0}-{1}-{2}-conduit-{3}.cmake".format(socket.gethostname(),
|
||||||
|
sys_type,
|
||||||
|
spec.compiler,
|
||||||
|
spec.dag_hash())
|
||||||
|
dest_dir = spec.prefix
|
||||||
|
host_config_path = os.path.abspath(join_path(dest_dir,
|
||||||
|
host_config_path))
|
||||||
|
return host_config_path
|
||||||
|
|
||||||
|
def hostconfig(self, spec, prefix):
|
||||||
"""
|
"""
|
||||||
This method creates a 'host-config' file that specifies
|
This method creates a 'host-config' file that specifies
|
||||||
all of the options used to configure and build conduit.
|
all of the options used to configure and build conduit.
|
||||||
|
|
||||||
For more details about 'host-config' files see:
|
For more details about 'host-config' files see:
|
||||||
http://software.llnl.gov/conduit/building.html
|
http://software.llnl.gov/conduit/building.html
|
||||||
|
|
||||||
Note:
|
|
||||||
The `py_site_pkgs_dir` arg exists to allow a package that
|
|
||||||
subclasses this package provide a specific site packages
|
|
||||||
dir when calling this function. `py_site_pkgs_dir` should
|
|
||||||
be an absolute path or `None`.
|
|
||||||
|
|
||||||
This is necessary because the spack `site_packages_dir`
|
|
||||||
var will not exist in the base class. For more details
|
|
||||||
on this issue see: https://github.com/spack/spack/issues/6261
|
|
||||||
"""
|
"""
|
||||||
|
if not os.path.isdir(spec.prefix):
|
||||||
|
os.mkdir(spec.prefix)
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Compiler Info
|
# Compiler Info
|
||||||
@ -308,8 +283,7 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||||||
f_compiler = env["SPACK_FC"]
|
f_compiler = env["SPACK_FC"]
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# By directly fetching the names of the actual compilers we appear
|
# Directly fetch the names of the actual compilers to create a
|
||||||
# to doing something evil here, but this is necessary to create a
|
|
||||||
# 'host config' file that works outside of the spack install env.
|
# 'host config' file that works outside of the spack install env.
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
@ -326,9 +300,9 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
cmake_exe = spec['cmake'].command.path
|
cmake_exe = spec['cmake'].command.path
|
||||||
host_cfg_fname = "%s-%s-%s-conduit.cmake" % (socket.gethostname(),
|
|
||||||
sys_type,
|
# get hostconfig name
|
||||||
spec.compiler)
|
host_cfg_fname = self._get_host_config_path(spec)
|
||||||
|
|
||||||
cfg = open(host_cfg_fname, "w")
|
cfg = open(host_cfg_fname, "w")
|
||||||
cfg.write("##################################\n")
|
cfg.write("##################################\n")
|
||||||
@ -448,10 +422,6 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||||||
cfg.write("# python from spack \n")
|
cfg.write("# python from spack \n")
|
||||||
cfg.write(cmake_cache_entry("PYTHON_EXECUTABLE",
|
cfg.write(cmake_cache_entry("PYTHON_EXECUTABLE",
|
||||||
spec['python'].command.path))
|
spec['python'].command.path))
|
||||||
# only set dest python site packages dir if passed
|
|
||||||
if py_site_pkgs_dir:
|
|
||||||
cfg.write(cmake_cache_entry("PYTHON_MODULE_INSTALL_PREFIX",
|
|
||||||
py_site_pkgs_dir))
|
|
||||||
else:
|
else:
|
||||||
cfg.write(cmake_cache_entry("ENABLE_PYTHON", "OFF"))
|
cfg.write(cmake_cache_entry("ENABLE_PYTHON", "OFF"))
|
||||||
|
|
||||||
@ -535,6 +505,17 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||||||
else:
|
else:
|
||||||
cfg.write("# hdf5 not built by spack \n")
|
cfg.write("# hdf5 not built by spack \n")
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# h5z-zfp
|
||||||
|
#######################
|
||||||
|
|
||||||
|
cfg.write("# h5z-zfp from spack \n")
|
||||||
|
|
||||||
|
if "+hdf5+zfp" in spec:
|
||||||
|
cfg.write(cmake_cache_entry("H5ZZFP_DIR", spec['h5z-zfp'].prefix))
|
||||||
|
else:
|
||||||
|
cfg.write("# h5z-zfp not built by spack \n")
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Silo
|
# Silo
|
||||||
#######################
|
#######################
|
||||||
@ -564,4 +545,3 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||||||
|
|
||||||
host_cfg_fname = os.path.abspath(host_cfg_fname)
|
host_cfg_fname = os.path.abspath(host_cfg_fname)
|
||||||
tty.info("spack generated conduit host-config file: " + host_cfg_fname)
|
tty.info("spack generated conduit host-config file: " + host_cfg_fname)
|
||||||
return host_cfg_fname
|
|
||||||
|
Loading…
Reference in New Issue
Block a user