def is_package(d):
    d = os.path.join(dir, d)
return os.path.isdir(d) and glob.glob(os.path.join(d, '__init__.py*'))
return list(filter(is_package, os.listdir(dir)))
Python: Finding all packages inside a package