跳转到主要内容

运行任何脚本的配方,以安装部分。

项目描述

此run-script URL允许您指定一个任意脚本以执行配方的功能。

详细文档

runscript Buildout配方

某些软件包不易使用“配置、构建、构建安装”等既定构建模式安装。在这些情况下,您希望能够使用任意脚本构建特定的部分。此配方提供了一种简单的实现方式,用于为每个安装和更新部分运行Python可调用。

>>> import os
>>> import z3c.recipe.runscript.tests
>>> scriptFilename = os.path.join(
...     os.path.dirname(z3c.recipe.runscript.tests.__file__), 'fooscripts.py')

让我们创建一个示例buildout来安装它

>>> write('buildout.cfg',
... """
... [buildout]
... parts = foo
...
... [foo]
... recipe = z3c.recipe.runscript
... install-script = %s:installFoo
... """ %scriptFilename)

install-script选项指定了部分安装期间要调用的模块和函数。该函数将本地和buildout选项作为参数。有关详细信息,请参阅tests/fooscripts.py

在运行buildout时,将调用installFoo()函数

>>> print system('bin/buildout')
Installing foo.
Now executing ``installFoo()``

如果我们再次运行buildout,将调用更新方法,但由于我们没有指定任何,因此不会发生任何操作

>>> print system('bin/buildout')
Updating foo.

现在让我们也指定更新脚本,这将导致调用updateFoo()函数

>>> write('buildout.cfg',
... """
... [buildout]
... parts = foo
...
... [foo]
... recipe = z3c.recipe.runscript
... install-script = %s:installFoo
... update-script = %s:updateFoo
... """ %(scriptFilename, scriptFilename))

但是,在发生此类更改后,部分将被卸载并重新安装

>>> print system('bin/buildout')
Uninstalling foo.
Installing foo.
Now executing ``installFoo()``

现在我们才能更新部分

>>> print system('bin/buildout')
Updating foo.
Now executing ``updateFoo()``

就这样。

变更日志

0.1.3 (2011-10-07)

  • Bug: 修复Windows路径支持(例如包含分号的“c:”)

0.1.2 (2010-09-22)

  • 添加了对 zope.testing 的测试依赖声明。

  • 使用 Python 的 doctest 模块,而不是已弃用的 zope.testing.doctest

0.1.1 (2008-04-18)

  • 错误:修复版本以包含 CHANGES.txt。

0.1.0 (2007-07-30)

  • 初始版本。

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪一个,请了解有关 安装包 的更多信息。

源分布

z3c.recipe.runscript-0.1.3.tar.gz (5.9 kB 查看散列值)

上传时间

支持