轻量级python构建工具。

exr-builder的Python项目详细描述


Build Status

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

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

我们感谢Raghunandan Rao所做的工作 并将更改的任何部分推到初始值 rags/pynt回购。

此exr builder项目的目标是支持exrny.com应用程序 具有轻量级和易于使用的python devops工具。我们要 积累由Raghunandan Rao完成的工作 还有其他的派特捐款人。我们自己的变化和新功能将 在这里实现并作为pr推送到原始pynt repo。

python构建的pynt。

功能

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

TOdo功能

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

安装

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

使用pip

$ pip install exr-builder

使用简易安装

$ easy_install exr-builder

示例

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

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

build.py

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

运行exr生成器任务

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

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

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

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

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

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

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

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

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

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

$ exrb 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/exrny/exr-builder。你需要 pytest运行测试

$ ./b t

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

如果您发现任何错误或需要新功能,请在 ^的{a13} Github回购。

许可证

exr builder是根据MIT license

更改

0.1.0-04/02/2018

  • 初始提交

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

推荐PyPI第三方库


热门话题
java JavaFX项目未显示   java JOGL启动时间太长   在Java中运行perl脚本   java在安卓中从json获得空字符串   java libgdx设置未设置java_主页   java Tomcat术语:停止vs杀死   java Hibernate:在数据库中将缺少参数的数据集插入为null   java如何创建一个类来扩展Android中的SparseArray?   java媒体播放器﹕ 错误(12147483648)   java将list1添加到list2并在不影响list2的情况下更新list1   java在JdbcCursorItemReader中打开CURSOR之前和关闭CURSOR之后执行SQL查询   基于注释的项目的java Spring集成“Integrationgraph”视图   java通过使用try-catch避免了无休止的空/空检查   素数序列