我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用pkg_resources.safe_extra()。
def generate_requirements(extras_require): """ Convert requirements from a setup()-style dictionary to ('Requires-Dist', 'requirement') and ('Provides-Extra', 'extra') tuples. extras_require is a dictionary of {extra: [requirements]} as passed to setup(), using the empty extra {'': [requirements]} to hold install_requires. """ for extra, depends in extras_require.items(): condition = '' if extra and ':' in extra: # setuptools extra:condition syntax extra, condition = extra.split(':', 1) extra = pkg_resources.safe_extra(extra) if extra: yield ('Provides-Extra', extra) if condition: condition += " and " condition += "extra == '%s'" % extra if condition: condition = '; ' + condition for new_req in convert_requirements(depends): yield ('Requires-Dist', new_req + condition)