Package: panifex
Panifex: A Python Build SystemOverviewPanifex is a Python build system that easily allows you to tie together various
parts of a multi-stage build and to create reusable recipes.  It is a good
replacement formakeand related tools.Example UsageThe following example defines abake.pyscript that builds a tetris game from
its project root directory:#!/usr/bin/env python
from panifex import build, sh, provide, target, default

sh.env(CC="clang", CFLAGS=("-g", "-I./include"), LDFLAGS=("-lncurses", "-lpanel"))

def compile(src):
    return sh(
        "{CC} -c {CFLAGS} {input} -o {output}",
        input=src,
        output=Path(src).with_suffix(".o"),
    )

def link(executable, objects):
    return sh("{CC} {LDFLAGS} {input} -o {output}", input=objects, output=executable)

@provide
def sources():
    return Path.cwd().glob("**/*.c")

@target
def objects(sources):
    return [compile(src) for src in sources]

@default
def executable(objects):
    return link("ntetris2", objects)

build()In the above example, the following usage patterns are presented:build,sh,provide,target, anddefaultare imported frompanifexbuildis the default build factory thatprovide,target, anddefaultare bound to, and the functor that we'll need to invoke once we've defined
all of our provides and targets.shis a recipe factory for generating shell-based file recipes.provideindicates that the function provides a resource needed by other
resources or targets, but that it is not a targetable build artifact.targetindicates that the function provides a resource needed by
other resources or targets, and that it is a targetable build artifact.defaultindicates that this function is the default targetable build
artifact, and will be built if no targets are explicitly specified
when invokingbake.CC,CFLAGS, andLDFLAGSare defined as environment variables throughsh.env.sh.envextends the environment of theshrecipe factory with
additional variables that are interpolated into the command string and added
to the environment of commands run with this factory.  In addition to OS
environment variables which are added automatically as strings, lists or
tuples can be specified insh.envwhich will be interpolated correctly
into command format strings.compileis defined.  It is a normal function which calls theshfactory to
generate a recipe for creating an.ooutput file for the given source
file.compileis referred to as a "recipe function", because it is a
function that generates a recipe from arguments.  Calling this function
itself does not run any commands, but instead the recipe generated should be
returned from a build target, where it can be built in parallel with other
dependencies in the overall dependency tree.  Theinputandoutputparameters toshare special and essential:outputspecifies the name of the file that will be generated by the
shell recipe.  This is used to determine if the recipe actually needs
to be run, and identifies the file that should be cleaned up while
cleaning.inputis optional, and specifies the file(s) that will be used to
create the output.  If the output already exists but any of the input
files are newer, the output will be re-created.linkis defined as another recipe function for creating the final executable
from a list of object files.sourcesis a provider.  It defines the list of source files to be built.objectsis the first target.  It depends onsourcesbecause it has a
parameter namedsourceswhich is automatically injected with the result
fromsources, that being a list of source filenames.  It usescompileto
create a list of recipes and returns them.  Panifex will build these recipes
in parallel, spawning at maximum as many simultaneous processes as the
system has available processor cores.executableis the default target.  It depends onobjects, and as such won't
actually run until all of the object file recipes generated byobjectsare
done building.executabledoesn't receive the list of object recipes,
rather it receives a list containing all of the outputs specified by each
recipe, that being a list of object filenames.Release Notesv1.1: 07/16/2020Addedbake -lto list targets and their docstrings.v1.0: 07/10/2020BACKWARDS INCOMPATIBLE CHANGE: End support for class based build modules.v0.8: 07/04/2020Updated to support Xeno's new function providers, builds no longer have to be
modeled as classes, butbuild()must be called at the end of the script.v0.1: 01/02/2020Initial release.