Use find_packages code to find modules. Can find LOTS of modules.
        :return:
357165
def via_find_packages(self):  # type: () -> List[str]
        
        packages = []  # type: List[str]
        source = self.setup_py_source()
        if not source:
            return packages
        find_package_args = ""
        for row in source.split("\n"):
            if "find_packages" in row:
                logger.debug(row)
                if "find_packages()" in row:
                    packages = find_packages()
                else:
                    try:

                        find_package_args_source = row.split("(")[1].split(")")[0]
                        find_package_args = ast.literal_eval(find_package_args_source)
                        logger.debug(packages)
                    except:
                        logger.debug(source)
                        # raise
        if not find_package_args:
            packages = find_packages()
        else:
            try:
                # signature find(cls, where='.', exclude=(), include=('*',)):
                packages = find_packages(find_package_args)
            except:
                packages = find_packages()

        return packages
1040815
def find_compiled_files(self):
        
        files = self._find_files()
        self.announce(
            "found '{}' compiled python files in '{}'".format(
                len(files), self.root
            )
        )
        return files
431296
def _build_package_finder(options, index_urls, session):
        
        return PackageFinder(
            find_links=options.get('find_links'),
            index_urls=index_urls,
            allow_all_prereleases=options.get('pre'),
            trusted_hosts=options.get('trusted_hosts'),
            session=session,
        )
686298
def _import_packages(packages, optional=None):
    
    if not optional:
        optional = []

    package_references = set()

    # Check all reqiured packages
    failures = set()
    for package_name in packages:
        try:
            package_reference = __import__(package_name, globals(), locals(), [], 0)
            package_references.add(package_reference)
        except ImportError:
            failures.add(package_name)

    # Report aggregated list of import failures (save a developer time when building a new frozen environment)
    if failures:
        raise ImportError(u"Unable to find required packages: {0}".format(u", ".join(failures)))

    # Check all optional packages (and warn if some aren't found)
    failures = set()
    for package_name in optional:
        try:
            package_reference = __import__(package_name, globals(), locals(), [], 0)
            package_references.add(package_reference)
        except ImportError:
            failures.add(package_name)

    # Warn user which optional packages weren't found
    for failure in failures:
        warn(ImportWarning(u"Unable to import {0}".format(failure)))

    return package_references
1086973
def find_objects(modules):
    
    return {
        subclass.__name__: subclass
        for subclass in chain(
            get_all_subclasses(Object),
            get_all_subclasses(ObjectSet),
        )
        if subclass.__module__ in modules
    }
1109437
def find_classes_in_module(module, clstypes):
    
    classes = []
    for item in dir(module):
        item = getattr(module, item)
        try:
            for cls in clstypes:
                if issubclass(item, cls) and item != cls:
                    classes.append(item)
        except Exception as e:
            pass
    return classes
221675
def get_modules(folder):
    
    if is_frozen():
        # find modules in library.zip filename
        zipname = os.path.dirname(os.path.dirname(__file__))
        parentmodule = os.path.basename(os.path.dirname(__file__))
        with zipfile.ZipFile(zipname, 'r') as f:
            prefix = "%s/%s/" % (parentmodule, folder)
            modnames = [os.path.splitext(n[len(prefix):])[0]
              for n in f.namelist()
              if n.startswith(prefix) and "__init__" not in n]
    else:
        dirname = os.path.join(os.path.dirname(__file__), folder)
        modnames = get_importable_modules(dirname)
    for modname in modnames:
        try:
            name ="..%s.%s" % (folder, modname)
            yield importlib.import_module(name, __name__)
        except ImportError as msg:
            out.error("could not load module %s: %s" % (modname, msg))
359888
def submodules(self):
        
        submodules = []
        submodules.extend(self.modules)
        for p in self.packages:
            submodules.extend(p.submodules)
        return submodules
105853
def find_packages(where='.', exclude=(), invalidate_cache=False):
    

    if exclude:
        warnings.warn(
            "Use of the exclude parameter is no longer supported since it does "
            "not work as expected. Use add_exclude_packages instead. Note that "
            "it must be called prior to any other calls from setup helpers.",
            AstropyDeprecationWarning)

    # Calling add_exclude_packages after this point will have no effect
    _module_state['excludes_too_late'] = True

    if not invalidate_cache and _module_state['package_cache'] is not None:
        return _module_state['package_cache']

    packages = _find_packages(
        where=where, exclude=list(_module_state['exclude_packages']))
    _module_state['package_cache'] = packages

    return packages
294740
def find_files(self):
        
        modules = self.evernode_app.get_modules()
        root_path = sys.path[0] if self.evernode_app.root_path is None \
            else self.evernode_app.root_path
        dirs = [dict(
            dir=os.path.join(root_path, 'resources', 'lang'), module="root")]
        for module_name in modules:
            modules_folder = 'modules{}%s'.format(os.sep)
            if module_name is not None:
                modules_folder = modules_folder % (module_name.strip(os.sep))
            else:
                continue
            path = os.path.join(
                root_path, modules_folder, 'resources', 'lang')
            if os.path.isdir(path):
                dirs.append(dict(dir=path, module=module_name))
        for dir in dirs:
            module_pack = {
                'name': dir['module'],
                'languages': [],
                'file_packs': []
            }
            for path, subdirs, files in os.walk(dir['dir']):
                for subdir in subdirs:
                    module_pack['languages'].append(subdir)
                for name in files:
                    module_pack['file_packs'].append(dict(
                        file=os.path.join(path, name),
                        name=name.rsplit('.', 1)[0].lower(),
                        language=path.split("lang%s" % (os.sep), 1)[1].strip()
                    ))
            self.module_packs.append(module_pack)
        for module_pack in self.module_packs:
            module_pack['file_packs'] = \
                list({v['file']: v for v in module_pack['file_packs']}
                     .values())
        if self.app.config['DEBUG']:
            print('--- Loaded Language Files ---')
            print("Loaded Dirs: " + str(dirs))
            print("Loaded Language Packs: " + str(self.module_packs))
174613
def find_missing_modules():
    
    missing_modules = []

    for module in MODULES:
        try:
            __import__(module[1])
        except ImportError:
            missing_modules.append(module)
    return missing_modules
77548
function findPackages(packagesPath) {
  return fs.readdirSync(packagesPath).reduce((acc, d) => {
    const fullpath = path.resolve(packagesPath, d);

    if (fs.statSync(fullpath).isDirectory()) {
      try {
        fs.statSync(path.resolve(fullpath, 'package.json'));
        acc.push(fullpath);
      }
      catch (err) {
        if (err.code === 'ENOENT') {
          return acc.concat(findPackages(fullpath));
        }
        throw err;
      }
    }

    return acc;
  }, []);
}
1331430
def find_top_level_modules_by_dunder_init(self):  # type: () -> List[str]
        
        # TODO: use package_dirs
        packaged_dirs = ""
        try:
            # Right now only returns 1st.
            packaged_dirs = self.extract_package_dir()
        except:
            pass
        likely_src_folders = [".", "src", "lib"]
        if packaged_dirs and packaged_dirs not in likely_src_folders:
            likely_src_folders.append(packaged_dirs)

        candidates = []
        for likely_src in likely_src_folders:
            if not os.path.isdir(likely_src):
                continue
            folders = [
                f
                for f in os.listdir(likely_src)
                if os.path.isdir(os.path.join(likely_src, f))
            ]

            for folder in folders:
                if os.path.isfile(os.path.join(likely_src, folder, "__init__.py")):
                    # dunder_source = self.file_opener.read_file(folder + "/__init__.py")
                    candidates.append(folder)

        return list(set([x for x in candidates if x]))
172311
def available(self):
        

        for module_name in self.packages:
            if importlib.util.find_spec(module_name):
                return True
        return False
68200
def collect_modules(self):
        
        try:
            res = {}
            m = sys.modules
            for k in m:
                # Don't report submodules (e.g. django.x, django.y, django.z)
                # Skip modules that begin with underscore
                if ('.' in k) or k[0] == '_':
                    continue
                if m[k]:
                    try:
                        d = m[k].__dict__
                        if "version" in d and d["version"]:
                            res[k] = self.jsonable(d["version"])
                        elif "__version__" in d and d["__version__"]:
                            res[k] = self.jsonable(d["__version__"])
                        else:
                            res[k] = get_distribution(k).version
                    except DistributionNotFound:
                        pass
                    except Exception:
                        logger.debug("collect_modules: could not process module: %s" % k)

        except Exception:
            logger.debug("collect_modules", exc_info=True)
        else:
            return res
910806
def find(self, package, **kwargs):
        
        spec = find_spec(package)
        if spec is None:
            return None
        limit = []
        if '.' in package:
            package, limit = package.split('.', 1)
            limit = [limit]
            spec = find_spec(package)
        if spec is not None:
            if spec.submodule_search_locations:
                path = spec.submodule_search_locations[0]
            elif spec.origin and spec.origin != 'built-in':
                path = spec.origin
            else:
                return None
            return PackageSpec(spec.name, path, limit)
        return None
623643
def _find_modules(src):
    """"""
    directors = 0
    mnames = []
    try:
        matches = _reModule.findall(open(src).read())
    except IOError:
        # If the file's not yet generated, guess the module name from the file stem
        matches = []
        mnames.append(os.path.splitext(os.path.basename(src))[0])

    for m in matches:
        mnames.append(m[2])
        directors = directors or m[0].find('directors') >= 0
    return mnames, directors