def recursive_package_list(*packages):
    """
    Returns a list of all the given packages and all their subpackages.

    Given packages are expected to be found relative to this script's location.

    Subpackages are detected by scanning the given packages' subfolder
    hierarchy for any folders containing the '__init__.py' module. As a
    consequence, namespace packages are not supported.

    This is our own specialized setuptools.find_packages() replacement so we
    can avoid the setuptools dependency.

    """
    result = set()
    todo = []
    for package in packages:
        folder = os.path.join(script_folder, *package.split("."))
        if not os.path.isdir(folder):
            raise Exception("Folder not found for package '%s'." % (package,))
        todo.append((package, folder))
    while todo:
        package, folder = todo.pop()
        if package in result:
            continue
        result.add(package)
        for subitem in os.listdir(folder):
            subpackage = ".".join((package, subitem))
            subfolder = os.path.join(folder, subitem)
            if not os.path.isfile(os.path.join(subfolder, "__init__.py")):
                continue
            todo.append((subpackage, subfolder))
    return list(result)
def recursive_package_list ( * packages ) : result = set ( ) todo = [ ] for package in packages : folder = os . path . join ( script_folder , * package . split ( "." ) ) if not os . path . isdir ( folder ) : raise Exception ( "Folder not found for package '%s'." % ( package , ) ) todo . append ( ( package , folder ) ) while todo : package , folder = todo . pop ( ) if package in result : continue result . add ( package ) for subitem in os . listdir ( folder ) : subpackage = "." . join ( ( package , subitem ) ) subfolder = os . path . join ( folder , subitem ) if not os . path . isfile ( os . path . join ( subfolder , "__init__.py" ) ) : continue todo . append ( ( subpackage , subfolder ) ) return list ( result )
Returns a list of all the given packages and all their subpackages.

    Given packages are expected to be found relative to this script's location.

    Subpackages are detected by scanning the given packages' subfolder
    hierarchy for any folders containing the '__init__.py' module. As a
    consequence, namespace packages are not supported.

    This is our own specialized setuptools.find_packages() replacement so we
    can avoid the setuptools dependency.