Blueprints
- class helix.blueprint.Blueprint(build_name, components=None, transforms=None, *args, **kwargs)
A common base class for all blueprints.
- abstract property callsites
A list of valid callsites which Components may use.
A good practice is to define these as constants on the Blueprint class as well so they may be referenced directly by components and don’t rely on matched strings.
- sane()
Ensure the current list of components is sane.
This method is optional and allows the developer to define additional constraints on the components supported by this Blueprint. This method should raise exceptions if the build is not sane.
- property tags
Returns the union of all tags involved in this blueprint.
Simply aggregates and dedups all tags on Components and Transforms.
- property functions
Aggregate all functions from included Components.
- property calls
Aggregate all calls from included Components.
- abstract generate(directory)
Generates a source directory from an interable of components.
The components passed to this class wll be finalized prior to calling this so that their source code is readily available. This function is responsible for writing configured components to the target output directory.
- Parameters
directory (str) – A directory to write the resulting generated source code - you may assume that this directory already exists and is writable.
- Returns
A list of generated source files.
Note
Component order matters here - this is the order in which calls and includes will be inserted into the generated source so if this is important you should make sure the order of components passed to this function is what you want.
- transform(type, targets)
Applies all Transforms of a given type.
- Parameters
type (str) – The type of transform to apply.
targets (str) – A list of targets to transform.
- abstract compile(directory, options)
Compiles the target directory.
Compiles a directory generated with
generate
, applies any artifact transformations, and returns a list of build artifacts.- Parameters
directory (str) – A directory with generated source code.
options (dict) – An optional dictionary of additional build options that should be respected by this function. This will contain things like
stdout
,stderr
andpropagate
for display options.
- Returns
A list of built artifacts.
Note
In practice this may frequently just be a bunch of calls to
os.system
to invoke the target build system of this Blueprint.
- build(directory, options=None)
Fully builds this Blueprint.
Generates code from Components, applies source Transforms, compiles code, and applies artifact Transforms.
- Parameters
directory (str) – A directory to write the resulting generated source code.
options (dict) – An optional dictionary of additional build options that should be used by
compile
.
- Returns
A list of built and transformed artifacts.
- classmethod install(verbose=False)
Install all dependencies.
This reruns dependency installation regardless of if it has been installed already. This should be safe because of the requirement that dependency installation methods be repeatable but can be inefficient. Users can check the
installed()
method to determine if the installation should be rerun.- Parameters
verbose (bool) – Verbosity.
- classmethod installed()
Check if all dependencies have been installed.
- Returns
True
if all dependencies have been installed already, andFalse
otherwise.
- abstract property name
A simple name.
Names should consist of [a-z-]. Make use of the optional
verbose_name
property if you would like a pretty-printable version of this name.
- abstract property type
A short type descriptor.
This should be set to some constant (a short string) defined in some common location.
- abstract property verbose_name
Optional verbose name for pretty printing.
By default this will just return
name
.
- abstract property version
A version number.
This should be a string using Semantic Versioning.