def _process_found_modules(py_dir, finder_info, modules, distributions,
                           prefixes, local_modules, orphans, not_found, logger):
    """ Use ModuleFinder data to update distributions and local_modules. """
    working_set = pkg_resources.WorkingSet()
    py_version = 'python%s' % sys.version[:3]

    for name, path in sorted(finder_info, key=lambda item: item[0]):
        if name in modules:
            continue
        if name != '__main__':
            modules.add(name)
        # Just being defensive, ModuleFinder should be excluding these.
        if not path:  #pragma no cover
            continue

        dirpath = os.path.realpath(os.path.dirname(path))
        if dirpath.startswith(py_dir):
            # May need to be copied later.
            local_modules.add(path)
            continue

        # Ignore modules never imported.
        if name not in sys.modules:
            continue

        # Skip modules in distributions we already know about.
        found = False
        for prefix in prefixes:
            if dirpath.startswith(prefix):
                found = True
                break
        if found:
            continue

        # Record distribution.
        for dist in working_set:
            loc = dist.location
            # Protect against a 'bare' location.
            if loc.endswith('dist-packages') or \
               loc.endswith('site-packages') or loc.endswith(py_version):
                loc = os.path.join(loc, dist.project_name)
            if dirpath.startswith(loc):
                distributions.add(dist)
                if loc.endswith('.egg'):
                    prefixes.add(loc)
                break
        else:
            if dirpath not in not_found:
                if not dirpath.endswith('dist-packages') and \
                   not dirpath.endswith('site-packages'):
                    not_found.add(dirpath)
                    path = dirpath
                if (name, path) not in orphans:
                    logger.warning('No distribution found for %s.', name)
                    orphans.add((name, path))
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.util/src/openmdao/util/eggsaver.py/_process_found_modules/original