Set MPI wrappers after confirming the package needs to be built

Because the cleaning of environment variables is only after the building
of a package, so MPI related stuffs should be only set when a package
needs to be built.