def _mark_plugins_for_rewrite(self, hook):
import pkg_resources<EOL>self.pluginmanager.rewrite_hook = hook<EOL>if os.environ.get("<STR_LIT>"):<EOL><INDENT>return<EOL><DEDENT>metadata_files = "<STR_LIT>", "<STR_LIT>"<EOL>package_files = (<EOL>entry.split("<STR_LIT:U+002C>")[<NUM_LIT:0>]<EOL>for entrypoint in pkg_resources.iter_entry_points("<STR_LIT>")<EOL>for metadata in metadata_files<EOL>for entry in entrypoint.dist._get_metadata(metadata)<EOL>)<EOL>for name in _iter_rewritable_modules(package_files):<EOL><INDENT>hook.mark_rewrite(name)<EOL><DEDENT>
Given an importhook, mark for rewrite any top-level
modules or packages in the distribution package for
all pytest plugins.