轻量级python构建工具。
vulcan-builder的Python项目详细描述
Vulcan生成器
这个项目是由Raghunandan Rao开发的。我们将为 原始RAGS/PYNT回购协议。
vulcan builder通过一个轻量级、简洁的 python devops工具。我们将在最初的基础上发展我们自己的改进 这里是rags/pynt repo,并发布对原始repo的改进。
这是一个exr开源项目。
python构建的pynt。
功能
- 易学。
- 构建任务只是python的功能。
- 管理任务之间的依赖关系。
- 自动生成命令行界面。
- rake样式的参数传递给任务
- 支持Python2.7和Python3.x
- 异步任务
TOdo功能
- 其他任务计时报告
- 调试模式
安装
您可以从python包索引(pypi)或 从源头上。
使用pip
$ pip install vulcan-builder
使用简易安装
$ easy_install vulcan-builder
示例
构建脚本是用纯python编写的,vulcan builder负责 管理任务之间的任何依赖关系并生成命令行 接口。
编写构建任务非常简单,您只需要知道@task 装饰工。任务只是用 @task()装饰器。依赖项也用@task()指定。 可以使用@task(ignore=True)忽略任务。禁用任务 是一个有用的特性,可以在您有一个任务 许多其他任务都依赖于,您希望快速将其从 所有依赖任务的依赖链。
build.py
#!/usr/bin/pythonimportsysfromvulcan.builderimporttask@task()defclean():'''Clean build directory.'''print'Cleaning build directory...'@task(clean)defhtml(target='.'):'''Generate HTML.'''print'Generating HTML in directory "%s"'%target@task(clean,ignore=True)defimages():'''Prepare images.'''print'Preparing images...'@task(html,images)defstart_server(server='localhost',port='80'):'''Start the server'''print'Starting server at %s:%s'%(server,port)@task(start_server)#Depends on task with all optional paramsdefstop_server():print'Stopping server....'@task()defcopy_file(src,dest):print'Copying from %s to %s'%(src,dest)@task()defecho(*args,**kwargs):printargsprintkwargs# Default task (if specified) is run when no task is specified in the command line# make sure you define the variable __DEFAULT__ after the task is defined# A good convention is to define it at the end of the module# __DEFAULT__ is an optional member__DEFAULT__=start_server
运行vulcan生成器任务
命令行界面和帮助将自动生成。任务 描述是从函数docstrings中提取的。
$ vb -h usage: vb [-h][-l][-v][-f file][task [task ...]] positional arguments: task perform specified task and all its dependencies optional arguments: -h, --help show this help message and exit -l, --list-tasks List the tasks -v, --version Display the version information -f file, --file file Build file to read the tasks from. Default is 'build.py'
$ vb -l Tasks in build file ./build.py: clean Clean build directory. copy_file echo html Generate HTML. images [Ignored] Prepare images. start_server [Default] Start the server stop_server Powered by vulcan-builder - A Lightweight Python Build Tool.
vulcan builder负责处理任务之间的依赖关系。在 以下案例启动服务器依赖于clean、html和图像生成 (忽略图像任务)。
$ vb #Runs the default task start_server. It does exactly what "vb start_server" would do. [ example.py - Starting task "clean"] Cleaning build directory... [ example.py - Completed task "clean"][ example.py - Starting task "html"] Generating HTML in directory "."[ example.py - Completed task "html"][ example.py - Ignoring task "images"][ example.py - Starting task "start_server"] Starting server at localhost:80 [ example.py - Completed task "start_server"]
任务名称的前几个字符足以执行任务, 只要部分名称是明确的。可以指定多个 要在命令行中运行的任务。再次获取依赖项 关心。
$ vb cle ht cl [ example.py - Starting task "clean"] Cleaning build directory... [ example.py - Completed task "clean"][ example.py - Starting task "html"] Generating HTML in directory "."[ example.py - Completed task "html"][ example.py - Starting task "clean"] Cleaning build directory... [ example.py - Completed task "clean"]
“html”任务依赖项“clean”只运行一次。但是干净可以 稍后再显式运行。
vb任务可以从命令行接受参数。
$ vb "copy_file[/path/to/foo, path_to_bar]"[ example.py - Starting task "clean"] Cleaning build directory... [ example.py - Completed task "clean"][ example.py - Starting task "copy_file"] Copying from /path/to/foo to path_to_bar [ example.py - Completed task "copy_file"]
vb也可以接受关键字参数。
$ vb start[port=8888][ example.py - Starting task "clean"] Cleaning build directory... [ example.py - Completed task "clean"][ example.py - Starting task "html"] Generating HTML in directory "."[ example.py - Completed task "html"][ example.py - Ignoring task "images"][ example.py - Starting task "start_server"] Starting server at localhost:8888 [ example.py - Completed task "start_server"] $ vb echo[hello,world,foo=bar,blah=123][ example.py - Starting task "echo"]('hello', 'world'){'blah': '123', 'foo': 'bar'}[ example.py - Completed task "echo"]
组织生成脚本
您可以将构建文件分解为模块并简单地导入它们 在主生成文件中。
fromdeploy_tasksimport*fromtest_tasksimportfunctional_tests,report_coverage
贡献者/贡献者
- raghunandan rao-vulcan builder前面是 pynt,它是由 Raghunandan Rao。
- calum j.eadie-pynt前面是 microbuild,这是 由Calum J. Eadie创建。
如果您想进行更改,回购协议位于 https://github.com/exrny/vulcan-builder。你需要 pytest运行测试
$ ./vb t
如果你能提高一次pull request那就太好了 你完了。
如果您发现任何错误或需要新功能,请在 issues section的 Github回购协议。
许可证
vulcan builder是根据MIT license
更改
0.1.0-04/02/2018
- 初始提交