multipackage.utilities.packages module

Utilities for finding python packages.

Summary

Functions:

find_toplevel_packages Find all top level python packages in the given directory.

Reference

multipackage.utilities.packages.find_toplevel_packages(path, exclude=('test', ), prefix=None)[source]

Find all top level python packages in the given directory.

This will automatically exclude all subpackages and only report the top level package. If you pass a prefix argument, then only the top level packages under that prefix will be reported.

So, if you have a package hierarchy like:

multipackage.core multipackage.plugins other_package.hello

and you pass prefix=”multipackage”, then you will get multipackage.core multipackage.plugins

Otherwise you will get: multipackage other_package

Parameters:
  • path (str) – The path to the directory in which to search
  • exclude (list of str) – Exclude the given packages
  • prefix (str) – Optional package prefix to search under. If this is not None then it must not end with a . and will be used to find the next level of packages under a given prefix.
Returns:

The list of top level packages.

Return type:

list of str