'Run after install to tell the configuration files to
use the compilers that Spack built the package with.
If this isn\'t done, they\'ll have PLUGIN_CXX set to
Spack\'s generic cxx. We want it to be bound to
whatever compiler it was built with.'

@run_after('install')
def filter_compilers(self, spec, prefix):

    kwargs = {'ignore_absent': True, 'backup': False, 'string': True}
    cc_files = ['bin/psi4-config']
    cxx_files = ['bin/psi4-config', 'include/psi4/psiconfig.h']
    template = 'share/psi4/plugin/Makefile.template'
    for filename in cc_files:
        filter_file(os.environ['CC'], self.compiler.cc, os.path.join(prefix, filename), **kwargs)
    for filename in cxx_files:
        filter_file(os.environ['CXX'], self.compiler.cxx, os.path.join(prefix, filename), **kwargs)
    filter_file('@PLUGIN_CXX@', self.compiler.cxx, os.path.join(prefix, template), **kwargs)
    filter_file('@PLUGIN_INCLUDES@', '-I{0}'.format('    -I'.join([os.path.join(spec['psi4'].prefix.include, 'psi4'), os.path.join(spec['boost'].prefix.include, 'boost'), os.path.join(spec['python'].headers.directories[0]), spec['lapack'].prefix.include, spec['blas'].prefix.include, '/usr/include'])), os.path.join(prefix, template), **kwargs)
