当前位置: 首页>>代码示例>>Python>>正文


Python Distribution.get_option_dict方法代码示例

本文整理汇总了Python中setuptools.dist.Distribution.get_option_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Distribution.get_option_dict方法的具体用法?Python Distribution.get_option_dict怎么用?Python Distribution.get_option_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在setuptools.dist.Distribution的用法示例。


在下文中一共展示了Distribution.get_option_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wrap_commands

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import get_option_dict [as 别名]
def wrap_commands(kwargs):
    dist = Distribution()

    # This should suffice to get the same config values and command classes
    # that the actual Distribution will see (not counting cmdclass, which is
    # handled below)
    dist.parse_config_files()

    for cmd, _ in dist.get_command_list():
        hooks = {}
        for opt, val in dist.get_option_dict(cmd).items():
            val = val[1]
            if opt.startswith('pre_hook.') or opt.startswith('post_hook.'):
                hook_type, alias = opt.split('.', 1)
                hook_dict = hooks.setdefault(hook_type, {})
                hook_dict[alias] = val
        if not hooks:
            continue

        if 'cmdclass' in kwargs and cmd in kwargs['cmdclass']:
            cmdclass = kwargs['cmdclass'][cmd]
        else:
            cmdclass = dist.get_command_class(cmd)

        new_cmdclass = wrap_command(cmd, cmdclass, hooks)
        kwargs.setdefault('cmdclass', {})[cmd] = new_cmdclass
开发者ID:HeLiHarvard,项目名称:Nomad,代码行数:28,代码来源:util.py

示例2: wrap_commands

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import get_option_dict [as 别名]
def wrap_commands(kwargs):
    dist = Distribution()

    # This should suffice to get the same config values and command classes
    # that the actual Distribution will see (not counting cmdclass, which is
    # handled below)
    dist.parse_config_files()

    # Setuptools doesn't patch get_command_list, and as such we do not get
    # extra commands from entry_points.  As we need to be compatable we deal
    # with this here.
    for ep in pkg_resources.iter_entry_points('distutils.commands'):
        if ep.name not in dist.cmdclass:
            cmdclass = ep.resolve()
            dist.cmdclass[ep.name] = cmdclass

    for cmd, _ in dist.get_command_list():
        hooks = {}
        for opt, val in dist.get_option_dict(cmd).items():
            val = val[1]
            if opt.startswith('pre_hook.') or opt.startswith('post_hook.'):
                hook_type, alias = opt.split('.', 1)
                hook_dict = hooks.setdefault(hook_type, {})
                hook_dict[alias] = val
        if not hooks:
            continue

        if 'cmdclass' in kwargs and cmd in kwargs['cmdclass']:
            cmdclass = kwargs['cmdclass'][cmd]
        else:
            cmdclass = dist.get_command_class(cmd)

        new_cmdclass = wrap_command(cmd, cmdclass, hooks)
        kwargs.setdefault('cmdclass', {})[cmd] = new_cmdclass
开发者ID:david-caro,项目名称:pbr,代码行数:36,代码来源:util.py

示例3: wrap_commands

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import get_option_dict [as 别名]
def wrap_commands(kwargs):
    dist = Distribution()

    # This should suffice to get the same config values and command classes
    # that the actual Distribution will see (not counting cmdclass, which is
    # handled below)
    dist.parse_config_files()

    # Setuptools doesn't patch get_command_list, and as such we do not get
    # extra commands from entry_points.  As we need to be compatable we deal
    # with this here.
    for ep in pkg_resources.iter_entry_points('distutils.commands'):
        if ep.name not in dist.cmdclass:
            if hasattr(ep, 'resolve'):
                cmdclass = ep.resolve()
            else:
                # Old setuptools does not have ep.resolve, and load with
                # arguments is depricated in 11+.  Use resolve, 12+, if we
                # can, otherwise fall back to load.
                # Setuptools 11 will throw a deprication warning, as it
                # uses _load instead of resolve.
                cmdclass = ep.load(False)
            dist.cmdclass[ep.name] = cmdclass

    for cmd, _ in dist.get_command_list():
        hooks = {}
        for opt, val in dist.get_option_dict(cmd).items():
            val = val[1]
            if opt.startswith('pre_hook.') or opt.startswith('post_hook.'):
                hook_type, alias = opt.split('.', 1)
                hook_dict = hooks.setdefault(hook_type, {})
                hook_dict[alias] = val
        if not hooks:
            continue

        if 'cmdclass' in kwargs and cmd in kwargs['cmdclass']:
            cmdclass = kwargs['cmdclass'][cmd]
        else:
            cmdclass = dist.get_command_class(cmd)

        new_cmdclass = wrap_command(cmd, cmdclass, hooks)
        kwargs.setdefault('cmdclass', {})[cmd] = new_cmdclass
开发者ID:brianbruggeman,项目名称:pyscaffold,代码行数:44,代码来源:util.py


注:本文中的setuptools.dist.Distribution.get_option_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。