def get_submodules_from_dpath(dpath, only_packages=False, recursive=True):
    r"""
    Args:
        dpath (str): directory path
        only_packages (bool): if True returns only package directories,
            otherwise returns module files. (default = False)

    Returns:
        list: submod_fpaths

    CommandLine:
        python -m utool.util_dev --exec-get_submodules_from_dpath --only_packages

    Example:
        >>> # DISABLE_DOCTEST
        >>> # SCRIPT
        >>> from utool.util_dev import *  # NOQA
        >>> import utool as ut
        >>> dpath = ut.truepath_relative(ut.get_argval('--dpath', default='.'))
        >>> print(dpath)
        >>> only_packages = ut.get_argflag('--only_packages')
        >>> submod_fpaths = get_submodules_from_dpath(dpath, only_packages)
        >>> submod_fpaths = ut.lmap(ut.truepath_relative, submod_fpaths)
        >>> result = ('submod_fpaths = %s' % (ut.repr3(submod_fpaths),))
        >>> print(result)
    """
    import utool as ut
    submod_dpaths = [d for d in ut.ls_dirs(dpath) if ut.is_module_dir(d) ]
    if only_packages:
        submod_fpaths = submod_dpaths
    else:
        submod_fpaths = ut.ls_modulefiles(dpath)
    if recursive and len(submod_dpaths) > 0:
        recusive_results = [get_submodules_from_dpath(d, only_packages)
                            for d in submod_dpaths]
        submod_fpaths.extend(ut.flatten(recusive_results))
    return submod_fpaths