类似于手工制作的makefile,但使用python。
craft的Python项目详细描述
craft就像makefile,只是所有东西都是用原生python编写的。
安装
pip install craft
craft在python 2.7+和python 3.2+上工作。
狡猾的文件
craft将尝试读取当前目录中的crafty.py。 或者环境变量$CRAFTFILE。
示例crafty.py:
from craft import task, depends @task @depends('bar', 'foo') def cake(): """ Prints cake, and depends on foo & bar to run first """ print('Time for cake') @task def bar(): """ Prints bar """ print('bar') @task def foo(): print("Hi,I'm foo") @task def auto(): """ I will run when you supply no arguments to "craft". """ print("Auto - Doing my own thing. Which is 'foo' today.") foo() @task def setup(): """ I will run once on any call to "craft" """ print("Hello good sir, I'm the setup routine.")
用法
在包含crafty.py的目录中运行craft -h将 显示可用任务的列表。示例:
usage: craft [-h] [task [task ...]] positional arguments: task optional arguments: -h, --help show this help message and exit Available tasks: - cake: Prints cake, and depends on foo & bar to run first - auto: I will run when you supply no arguments to "craft". - setup: I will run once on any call to "craft" - foo: - bar: Prints bar
如您所见,然后将表示每个@task函数的docstring 在帮助输出中,可以省略docstring。
您可以调用个别任务,如:
craft foo
用一个调用运行多个任务,如:
craft foo bar
历史记录
2012年11月10日
- 修复setup.py链接到自述文件的问题
2012年10月14日
- 修复与工艺和实际任务的错误捕获隔离
2012年8月27日
- 添加了setup()和auto()任务
- 通过@depends添加了对任务依赖项的支持
2012年8月26日