def recipe(recipe_file, cpu_target=None, ctype=container_type.DOCKER,
           raise_exceptions=False, single_stage=False,
           singularity_version='2.6', userarg=None,
           working_directory='/var/tmp'):
    """Recipe builder

    # Arguments

    recipe_file: path to a recipe file (required).

    cpu_target: A CPU microarchitecture string recognized by archspec.

    ctype: Enum representing the container specification format.  The
    default is `container_type.DOCKER`.

    raise_exceptions: If False, do not print stack traces when an
    exception is raised.  The default value is False.

    single_stage: If True, only print the first stage of a multi-stage
    recipe.  The default is False.

    singularity_version: Version of the Singularity definition file
    format to use.  Multi-stage support was added in version 3.2, but
    the changes are incompatible with earlier versions of Singularity.
    The default is '2.6'.

    userarg: A dictionary of key / value pairs provided to the recipe
    as the `USERARG` dictionary.

    working_directory: path to use as the working directory in the
    container specification

    """

    # Make user arguments available
    USERARG = {} # pylint: disable=unused-variable
    if userarg:
        USERARG = userarg # alias

    # Consider just 2 stages for the time being
    stages = [Stage(), Stage()]
    Stage0 = stages[0] # alias # pylint: disable=unused-variable
    Stage1 = stages[1] # alias # pylint: disable=unused-variable

    # Set the CPU target
    hpccm.config.set_cpu_target(cpu_target)

    # Set the global container type
    hpccm.config.g_ctype = ctype

    # Set the global Singularity version
    hpccm.config.g_singularity_version = Version(singularity_version)

    # Set the global working directory
    hpccm.config.g_wd = working_directory

    # Any included recipes that are specified using relative paths will
    # need to prepend the path to the main recipe in order to be found.
    # Save the path to the main recipe.
    include.prepend_path = os.path.dirname(recipe_file)

    # Load in the recipe file
    include(recipe_file, _locals=locals(), _globals=globals(),
            prepend_path=False, raise_exceptions=raise_exceptions)

    # Only process the first stage of a recipe
    if single_stage:
        del stages[1:]
    elif len(Stage1) > 0:
        if (ctype == container_type.SINGULARITY and
            hpccm.config.g_singularity_version < Version('3.2')):
            # Singularity prior to version 3.2 did not support
            # multi-stage builds.  If the Singularity version is not
            # sufficient to support multi-stage, provide advice to
            # specify a sufficient Singularity version or disable
            # multi-stage.
            logging.warning('This looks like a multi-stage recipe. '
                            'Singularity 3.2 or later is required for '
                            'multi-stage builds.  Use '
                            '--singularity-version=3.2 to enable this '
                            'feature or --single-stage to get rid of this '
                            'warning.  Only processing the first stage...')
            del stages[1:]
        elif ctype == container_type.BASH:
            logging.warning('This looks like a multi-stage recipe, but '
                            'bash does not support multi-stage builds. '
                            'Use --single-stage to get rid of this warning. '
                            'Only processing the first stage...')
            del stages[1:]

    r = []
    for index, stage in enumerate(stages):
        if index >= 1:
            r.append('')
        r.append(str(stage))

    return '\n'.join(r)
Recipe builder

    # Arguments

    recipe_file: path to a recipe file (required).

    cpu_target: A CPU microarchitecture string recognized by archspec.

    ctype: Enum representing the container specification format.  The
    default is `container_type.DOCKER`.

    raise_exceptions: If False, do not print stack traces when an
    exception is raised.  The default value is False.

    single_stage: If True, only print the first stage of a multi-stage
    recipe.  The default is False.

    singularity_version: Version of the Singularity definition file
    format to use.  Multi-stage support was added in version 3.2, but
    the changes are incompatible with earlier versions of Singularity.
    The default is '2.6'.

    userarg: A dictionary of key / value pairs provided to the recipe
    as the `USERARG` dictionary.

    working_directory: path to use as the working directory in the
    container specification

    
hpccm/recipe.py