'Run after install to make the MPI compilers use the
compilers that Spack built the package with.
If this isn\'t done, they\'ll have CC, CXX, F77, and FC set
to Spack\'s generic cc, c++, f77, and f90.  We want them to
be bound to whatever compiler they were built with.'

@run_after('install')
def filter_compilers(self):

    bin = self.prefix.bin
    mpicc = join_path(bin, 'mpicc')
    mpicxx = join_path(bin, 'mpicxx')
    mpif77 = join_path(bin, 'mpif77')
    mpif90 = join_path(bin, 'mpif90')
    mpifort = join_path(bin, 'mpifort')
    kwargs = {'ignore_absent': True, 'backup': False, 'string': True}
    filter_file(env['CC'], self.compiler.cc, mpicc, **kwargs)
    filter_file(env['CXX'], self.compiler.cxx, mpicxx, **kwargs)
    filter_file(env['F77'], self.compiler.f77, mpif77, **kwargs)
    filter_file(env['FC'], self.compiler.fc, mpif90, **kwargs)
    filter_file(env['FC'], self.compiler.fc, mpifort, **kwargs)
    for wrapper in (mpicc, mpicxx, mpif77, mpif90, mpifort):
        filter_file('-Wl,--enable-new-dtags', '', wrapper, **kwargs)
