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


Python Distribution.get_command_class方法代码示例

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


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

示例1: wrap_commands

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import get_command_class [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_command_class [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_command_class [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

示例4: use_setuptools

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import get_command_class [as 别名]
# Install setuptools automagically from the interwebz
from ez_setup import use_setuptools
use_setuptools()

from setuptools import setup, find_packages

from setuptools.dist import Distribution
dist = Distribution()
setuptools_install = dist.get_command_class('install')
class MyInstall(setuptools_install):
    def run(self):
        klass = dist.get_command_obj('envpipinstall')
        klass.ensure_finalized()
        klass.run()
        klass.mod_klass_prefix_attributes(self)
        setuptools_install.run(self)

# Run setuptools setup
setup(
    name = "mocky",
    packages = find_packages(),
    setup_requires = [
        'pyenvpip',
    ],
    author = 'Tyghe Vallard',
    author_email = '[email protected]',
    license = 'GPLv3',
    cmdclass = {
        'install': MyInstall,
    }
)
开发者ID:necrolyte2,项目名称:pyenvpip,代码行数:33,代码来源:mock_setup.py


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