DEPRECATED: Use `xeno.build` in the `xeno` package instead.
Project description
Panifex: A Python Build System
Overview
Panifex 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 for make and related tools.
Example Usage
The following example defines a bake.py script 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 Notes
v1.1: 07/16/2020
- Added
bake -lto list targets and their docstrings.
v1.0: 07/10/2020
- BACKWARDS INCOMPATIBLE CHANGE: End support for class based build modules.
v0.8: 07/04/2020
- Updated to support Xeno's new function providers, builds no longer have to be
modeled as classes, but
build()must be called at the end of the script.
v0.1: 01/02/2020
- Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
panifex-1.1.2.tar.gz
(16.8 kB
view details)
File details
Details for the file panifex-1.1.2.tar.gz.
File metadata
- Download URL: panifex-1.1.2.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97668f1ef75893c7ec8f9b68f0f8dc04f5ba0faf837fb54092495490310eb82f
|
|
| MD5 |
129aa03a3c7a47d75b3f9c0a48fabf54
|
|
| BLAKE2b-256 |
29a3abbc8587f5ec4f70d42e2132afd7a37e91f98a4135d7191419d43b966695
|