autofeature自动注册zcml特性。
ftw.autofeature的Python项目详细描述
autofeature自动注册zcml特性。
附加功能
autofeature:extras指令自动为每个 额外的(extras_requires)包。 当额外项的每个依赖项 已安装。
示例
当使用这样的setup.py时:
fromsetuptoolsimportsetup,find_packagessetup(name='my.package',version='1.0.0dev0',packages=find_packages(exclude=['ez_setup']),namespace_packages=['my'],install_requires=['setuptools','ftw.autofeature',],extras_require={'tests':['unittest2'],'foo':['foo','foo-compat'],'bar':['bar','bar-compat']})
您可以让ftw.autofeature自动声明附加功能:
<configurexmlns="http://namespaces.zope.org/zope"xmlns:zcml="http://namespaces.zope.org/zcml"xmlns:autofeature="http://namespaces.zope.org/autofeature"><includepackage="ftw.autofeature"file="meta.zcml"/><autofeature:extras/><configurezcml:condition="have my.package:foo"><!-- foo things --></configure><configurezcml:condition="have my.package:bar"><!-- bar things --></configure><configurezcml:condition="have my.package:foo:bar"><!-- foo and bar things --></configure></configure>
功能my.package:foo仅在安装了附加功能时注册。 当同时安装foo和bar时,会注册多个功能,以便 很容易将附加功能与AND:
- my.package:foo
- my.package:foo:bar
- my.package:bar
- my.package:bar:foo
限制
我们无法真正检测是否在安装时明确使用了附加功能。 因此,我们测试是否安装了extras中的每个依赖项。 当每个依赖项都已安装但未显式安装附加项时,这也将 注册功能。
转储功能
autofeature:dump指令转储当前注册的zcml功能 达到标准。 只需使用指令在zcml中的任意点转储功能:
<configurexmlns="http://namespaces.zope.org/zope"xmlns:autofeature="http://namespaces.zope.org/autofeature"><includepackage="ftw.autofeature"file="meta.zcml"/><autofeature:dump/></configure>
链接
更改日志
1.0.0(2015-08-24)
- 初步实施 [乔恩]