'This method creates a \'host-config\' file that specifies
all of the options used to configure and build conduit.
For more details see about \'host-config\' files see:
http://software.llnl.gov/conduit/building.html'

def create_host_config(self, spec, prefix):

    c_compiler = env['SPACK_CC']
    cpp_compiler = env['SPACK_CXX']
    f_compiler = None
    if self.compiler.fc:
        if os.path.isfile(env['SPACK_FC']):
            f_compiler = env['SPACK_FC']
    sys_type = spec.architecture
    if ('SYS_TYPE' in env):
        sys_type = env['SYS_TYPE']
    if ('+cmake' in spec):
        cmake_exe = spec['cmake'].command.path
    else:
        cmake_exe = which('cmake')
        if (cmake_exe is None):
            msg = 'failed    to    find    CMake    (and    cmake    variant    is    off)'
            raise RuntimeError(msg)
        cmake_exe = cmake_exe.path
    host_cfg_fname = ('%s-%s-%s.cmake' % (socket.gethostname(), sys_type, spec.compiler))
    cfg = open(host_cfg_fname, 'w')
    cfg.write('##################################\n')
    cfg.write('#    spack    generated    host-config\n')
    cfg.write('##################################\n')
    cfg.write('#    {0}-{1}\n'.format(sys_type, spec.compiler))
    cfg.write('##################################\n\n')
    cfg.write('#    cmake    from    spack    \n')
    cfg.write(('#    cmake    executable    path:    %s\n\n' % cmake_exe))
    cfg.write('#######\n')
    cfg.write(('#    using    %s    compiler    spec\n' % spec.compiler))
    cfg.write('#######\n\n')
    cfg.write('#    c    compiler    used    by    spack\n')
    cfg.write(cmake_cache_entry('CMAKE_C_COMPILER', c_compiler))
    cfg.write('#    cpp    compiler    used    by    spack\n')
    cfg.write(cmake_cache_entry('CMAKE_CXX_COMPILER', cpp_compiler))
    cfg.write('#    fortran    compiler    used    by    spack\n')
    if (f_compiler is not None):
        cfg.write(cmake_cache_entry('ENABLE_FORTRAN', 'ON'))
        cfg.write(cmake_cache_entry('CMAKE_Fortran_COMPILER', f_compiler))
    else:
        cfg.write('#    no    fortran    compiler    found\n\n')
        cfg.write(cmake_cache_entry('ENABLE_FORTRAN', 'OFF'))
    cfg.write('#    Python    Support\n')
    if ('+python' in spec):
        cfg.write('#    Enable    python    module    builds\n')
        cfg.write(cmake_cache_entry('ENABLE_PYTHON', 'ON'))
        cfg.write('#    python    from    spack    \n')
        cfg.write(cmake_cache_entry('PYTHON_EXECUTABLE', spec['python'].command.path))
        cfg.write(cmake_cache_entry('PYTHON_MODULE_INSTALL_PREFIX', site_packages_dir))
    else:
        cfg.write(cmake_cache_entry('ENABLE_PYTHON', 'OFF'))
    if ('+doc' in spec):
        cfg.write(cmake_cache_entry('ENABLE_DOCS', 'ON'))
        cfg.write('#    sphinx    from    spack    \n')
        sphinx_build_exe = join_path(spec['py-sphinx'].prefix.bin, 'sphinx-build')
        cfg.write(cmake_cache_entry('SPHINX_EXECUTABLE', sphinx_build_exe))
        cfg.write('#    doxygen    from    uberenv\n')
        doxygen_exe = spec['doxygen'].command.path
        cfg.write(cmake_cache_entry('DOXYGEN_EXECUTABLE', doxygen_exe))
    else:
        cfg.write(cmake_cache_entry('ENABLE_DOCS', 'OFF'))
    cfg.write('#    MPI    Support\n')
    if ('+mpi' in spec):
        cfg.write(cmake_cache_entry('ENABLE_MPI', 'ON'))
        cfg.write(cmake_cache_entry('MPI_C_COMPILER', spec['mpi'].mpicc))
        cfg.write(cmake_cache_entry('MPI_CXX_COMPILER', spec['mpi'].mpicc))
        cfg.write(cmake_cache_entry('MPI_Fortran_COMPILER', spec['mpi'].mpifc))
    else:
        cfg.write(cmake_cache_entry('ENABLE_MPI', 'OFF'))
    cfg.write('#    I/O    Packages\n\n')
    cfg.write('#    hdf5    from    spack    \n')
    if ('+hdf5' in spec):
        cfg.write(cmake_cache_entry('HDF5_DIR', spec['hdf5'].prefix))
    else:
        cfg.write('#    hdf5    not    built    by    spack    \n')
    cfg.write('#    silo    from    spack    \n')
    if ('+silo' in spec):
        cfg.write(cmake_cache_entry('SILO_DIR', spec['silo'].prefix))
    else:
        cfg.write('#    silo    not    built    by    spack    \n')
    cfg.write('##################################\n')
    cfg.write('#    end    spack    generated    host-config\n')
    cfg.write('##################################\n')
    cfg.close()
    host_cfg_fname = os.path.abspath(host_cfg_fname)
    tty.info(('spack    generated    conduit    host-config    file:    ' + host_cfg_fname))
    return host_cfg_fname
