一个轻量级、多平台的python构建工具,考虑到了jenkins这样的持续集成服务器。
Dovetail的Python项目详细描述
燕尾榫是一个轻量级、多平台的python构建工具 考虑到像jenkins这样的持续集成服务器。
TL;DR
Builds are complex, integrate many tools and sometimes must run on many platforms. Writing good build scripts is hard.
Dovetail helps in all these areas, and is not a rip’n’replace for your existing tools. You can readily automate a build using Dovetail.
构建应用程序不仅仅是运行:
> python setup.py sdist
怎么样:
- Building binary distributions for several target platforms
- Building the user documentation and the API docs?
- Running your unit tests, sometimes using several test frameworks?
- Installing your application in a clean virtual environment and running user tests?
- Running code quality tools like Coverage and Pylint?
- Tagging your code in your DVCS?
- Uploading the artifacts to a repository? That’s probably at least an Egg, a source distribution, documentation and your web site
如何保证每个人,特别是新的团队成员 以同样的方式建造?
许多团队通过编写脚本来解决这个问题,但这会引发更多的问题:
- Do you have a lot of scripts lying around, each doing their own thing, and little shared code?
- Do you have operating system specific scripts that do the same thing, but on different operating systems?
- Are your scripts reliable and maintainable?
如果您需要在这些方面进行改进,dovetail可以帮助您。燕尾型:
- Is pure Python, so the build runs everywhere and is maintainable
- Provides a simple API to externalize many common build requirements
- There are no new configuration file formats or 4GLs of abstruse XML or other syntaxes
- Makes it simple to query the build environment and adjust the build appropriately
- Audits all the build steps and decisions
- Properly catches build errors and displays the details of what went wrong
- Makes it terribly easy to automate the build in a tool like Jenkins.
对维护人员来说,一个意想不到的好处是它变得更容易了 在我的ide中构建;我也从命令行获得完全相同的构建。
燕尾榫不能代替Setuptools 或distutils- 对于创建可分发的 包裹。
功能性
鸽尾构建脚本是标准python脚本函数声明为 在构建中通过装饰它们成为tasks。进一步的装饰声明:
- Task dependencies, with the same build script or across related files
- Required packages, which are downloaded and installed if not present
- Conditions, such as tests on environment variables or the file system.
- Build directory structure
- Error conditions, such as a non-zero return or output in stderr.
燕尾榫与许多其他工具一起工作,使构建步骤自动化,并且具有内置的 与Virtualenv集成。任何版本都可以 在路径上的python版本或任何指定的虚拟环境中运行。
鸠尾榫根据需要安装软件包,即使在构建过程中也是如此。这意味着 在复杂的构建中运行一个简单的任务,而不安装所有文档 以及测试包。
示例
下面给出了燕尾型构建脚本的一个小例子。它使用 Sphinx创建项目文档:
from dovetail import task, requires, check_result, call, mkdirs, do_if, IsDir from os import path from shutil import rmtree DOCSOURCE = path.abspath(path.join(path.dirname(__file__), "source")) BUILD = path.abspath(path.join(path.dirname(__file__), "..", "build")) @task # Declares the function clean() is a build task @do_if(IsDir(BUILD)) # Only run if the build directory exists def clean(): """Clean the project of all build artifacts""" rmtree(BUILD) @task # Declares the function clean() is a build task @requires('sphinx') # Ensures the sphinx package is installed @mkdirs(BUILD) # Make the build directory if it doesn't exist @check_result # Fails the build if sphinx fails def doc(): """Builds the Sphinx User documentation""" return call("sphinx-build {0} {1}".format(DOCSOURCE, BUILD).split(' '))
生成仅从操作系统命令行运行:
$ dovetail clean doc