loki.build.builder

Classes

Builder([source_dirs, include_dirs, ...])

A Builder that compiles binaries or libraries, while performing automated dependency discovery from one or more source paths.

class Builder(source_dirs=None, include_dirs=None, root_dir=None, build_dir=None, compiler=None, logger=None, workers=3)

Bases: object

A Builder that compiles binaries or libraries, while performing automated dependency discovery from one or more source paths.

Parameters:
  • sources – One or more paths to search for source files

  • includes – One or more paths to that include header files

get_item(key)
static get_dependency_graph(objs, depgen=None)

Construct a networkx.DiGraph that represents the dependency graph.

Parameters:
  • objs – List of Obj to use as the root of the graph.

  • depgen – Generator object to generate the next level of dependencies from an item. Defaults to operator.attrgetter('dependencies').

clean(rules=None, path=None)

Clean up a build directory according, either according to globbing rules or via explicit file paths.

Parameters:
  • rules – String or list of strings with either explicit filepaths or globbing rules; default is '*.o *.mod *.so f90wrap*.f90'.

  • path – Optional directory path to clean; defaults first to self.build_dir, then simply ./.

build(filename, target=None, shared=True, include_dirs=None, external_objs=None)
load_module(module)

Handle import paths and load the compiled module

wrap_and_load(sources, modname=None, build=True, libs=None, lib_dirs=None, incl_dirs=None, kind_map=None)

Performs the necessary build steps to compile and wrap a set of sources using f90wrap

This method returns a dynamically loaded Python module containinig wrappers for each Fortran procedure and module specified in sources.

Parameters:
  • source (str or list of str) – Name(s) of source files to wrap

  • modname (str, optional) – Optional module name for f90wrap to use

  • build (bool, optional) – Flag to force building the source first; default: True.

  • libs (list of str, optional) – Override for library names to link

  • lib_dirs (list of str, optional) – Override for library paths to link from

  • incl_dirs (list of str, optional) – Override for include directories

  • kind_map (str, optional) – Path to f90wrap KIND_MAP file, containing a Python dictionary in f2py_f2cmap format.