Build helper for setup script. It includes dependency checks and monkey-patch in order to extend or modify supporting system software locally (affecting only the running instance of the program).


The original version of this script was adapted from NiPy project.

class builder.Clean(dist)[source]

Distutils command class to clean. Enhanced to clean also files generated during python build_ext –inplace process.


Run clean process recursively for directories: petgem, examples, utils, tests, doc and root directory.

class builder.NoOptionsDocs(dist)[source]

Handler class for no options docs


Finalize options for NoOptionsDocs class.


Init options for NoOptionsDocs class.

user_options = [('None', None, 'this command has no options')]
class builder.SphinxHTMLDocs(dist)[source]

Generate html docs by Sphinx.


Run SphinxHTMLDocs class.

class builder.SphinxPDFDocs(dist)[source]

Generate pdf docs by Sphinx


Run SphinxPDFDocs class.


Get make command for Sphinx documentation.

builder.package_check(pkg_name, version=None, optional=False, checker=<class 'distutils.version.LooseVersion'>, version_getter=None, messages=None, show_only=False)[source]

Check if package pkg_name is present, and in correct version.

  • pkg_name (str,list) – the name of the package as imported into python. Alternative names (e.g. for different versions) may be given in a list.
  • version (str) – the minimum version of the package that is required. If not given, the version is not checked.
  • optional (bool) – if False, raise error for absent package or wrong version, otherwise warning.
  • checker (callalble) – if given, the callable with which to return a comparable thing from a version string. The default is distutils.version.LooseVersion.
  • version_getter (callable) –

    if given, the callable that takes pkg_name as argument, and returns the package version string as in:

    version = version_getter(pkg_name)

    The default is equivalent to:

    mod = __import__(pkg_name); version = mod.__version__
  • messages (dict) – if given, the dictionary providing (some of) output messages.
  • show_only (bool) – if True, do not raise exceptions, only show the package name and version information.
builder.recursive_glob(top_dir, pattern)[source]

Finds all the pathnames matching a specific pattern according to the rules used by Unix shell. recursive_glob works like glob.glob(), but in working recursively.

  • top_dir (str) – the top-level directory
  • pattern (str,list) – the pattern or list of patterns to match

Unitary test for script. Check if version, top_dir and in_source are present in INFO PETGEM object.