轻量级python构建工具

navio-builder的Python项目详细描述


Build Status

为什么我要做这个叉子,这里会发生什么?

这个项目是由Pynt提供的。Raghunandan Rao

我欣赏Raghunandan Rao的作品 并将我的更改的任何部分推到初始 rags/pynt回购。

这个navio builder项目的目的是为我的客户提供 轻量级且易于使用的python devops工具。我要积累 由Raghunandan Rao和其他人完成的工作 这里是Pynt出资人。我自己的变化和新功能 在这里实现并作为pr推送到原始pynt repo。

python构建的pynt。

功能

  • 易学。
  • 构建任务只是python的功能。
  • 管理任务之间的依赖关系。
  • 自动生成命令行界面。
  • rake样式的参数传递给任务
  • 支持Python2.7和Python3.x

TOdo功能

  • 异步任务
  • 其他任务计时报告

安装

可以从python包索引(pypi)或 从源头上。

使用pip

$ pip install navio-builder

使用简易安装

$ easy_install navio-builder

示例

构建脚本是用纯python编写的,navio builder负责 管理任务之间的任何依赖关系并生成命令行 接口。

编写构建任务非常简单,您只需要知道@task 装饰工。任务只是用 @task()装饰器。依赖项也用@task()指定。 可以使用@task(ignore=True)忽略任务。禁用任务 是一个有用的特性,可以在您有一个任务 许多其他任务都依赖于,您希望快速将其从 所有依赖任务的依赖链。

build.py

#!/usr/bin/pythonimportsysfromnavio.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

运行Navio Builder任务

命令行界面和帮助将自动生成。任务 描述是从函数docstrings中提取的。

$ nb -h
usage: nb [-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'
$ nb -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 navio-builder - A Lightweight Python Build Tool.

navio builder负责处理任务之间的依赖关系。在下面 case start_服务器依赖于clean、html和图像生成(图像 任务被忽略)。

$ nb #Runs the default task start_server. It does exactly what "nb 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"]

任务名称的前几个字符足以执行任务, 只要部分名称是明确的。可以指定多个 要在命令行中运行的任务。再次获取依赖项 关心。

$ nb 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”只运行一次。但是干净可以 稍后再显式运行。

nb任务可以从命令行接受参数。

$ nb "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"]

nb还可以接受关键字参数。

$ nb 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"]

$ nb 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

贡献者/贡献者

如果您想进行更改,回购协议位于 https://github.com/naviotech/navio-builder。你需要 pytest运行测试

$ ./b t

如果你能提高一次pull request那就太好了 你完了。

如果您发现任何错误或需要新功能,请在 issues section Github回购协议。

许可证

navio builder是根据MIT license

更改

0.1.16-14/12/2017

  • 将任务运行时间添加到输出

0.1.0-11/12/2017

  • 初次发布。派特的叉子。
  • 将“完成”重命名为模块

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何删除TextInputLayout提示文本中的省略号(三个点)?   java通过蓝牙编程发送数据   java如何在Opengl ES中获得一个像素的透明颜色?   java如何在添加额外的maven依赖项后更新eclipse项目   Java机器人编程。在拾取和放置任务中移动零件时,如何跟踪零件的属性?   json如何使用Java访问JSONObject中的JSONArray?   Java将列表组的字段(BigDecimal)乘以2个字段求和   Java:从URL下载   java多ajax数据到Spring MVC控制器   java使用Android将文本文件上传到Google Drive   java使用org解析多个模式。三十。英国石油公司。总体安排日期时间格式化程序   安卓 java中的机器人选择测试。lang.NoSuchFieldError:在应用窗口侦听器上标记   BeanPostProcessor的java示例   java为什么这段代码在这里给我一个空异常错误?   java如何解析一个字符串并获得一个子字符串?   java:使用vfs S3插件在AmazonS3中使用服务器端加密