def _gather_package(self, package, rootdir, relpath):
        """Recursively gather a python package directory into the bundle.

        Given the name of the python package, the root import directory under
        which it was found, and the relative path from that root to the
        package directory, this method copies the package and all its contents
        into the bundle and adds them to the list of available modules.
        """
        abspath = os.path.join(rootdir, relpath)
        subpackage = os.path.basename(abspath)
        if package:
            subpackage = package + "." + subpackage
        if not self.is_excluded(subpackage):
            # Note it as an available package.
            self.modules[subpackage] = {"dir": relpath.replace("\\", "/")}
            if not os.path.isdir(os.path.join(self.bundle_dir, relpath)):
                os.makedirs(os.path.join(self.bundle_dir, relpath))
            # Include it in post-gathering analysis.
            self._modules_pending_import_analysis.append(subpackage)
            # Recursively gather all its contents.
            for nm in os.listdir(abspath):
                nm = _u(nm)
                if nm.startswith("."):
                    continue
                subrelpath = os.path.join(relpath, nm)
                subabspath = os.path.join(abspath, nm)
                if os.path.isdir(subabspath):
                    if os.path.exists(os.path.join(subabspath, "__init__.py")):
                        self._gather_package(subpackage, rootdir, subrelpath)
                elif nm.endswith(".py"):
                    self._gather_module(subpackage, rootdir, subrelpath)
Recursively gather a python package directory into the bundle.

        Given the name of the python package, the root import directory under
        which it was found, and the relative path from that root to the
        package directory, this method copies the package and all its contents
        into the bundle and adds them to the list of available modules.
        
tools/module_bundler.py