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


Python Distribution.get_option_dict方法代码示例

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


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

示例1: _do_download

# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import get_option_dict [as 别名]
def _do_download(self, version='', find_links=None):
        if find_links:
            allow_hosts = ''
            index_url = None
        else:
            allow_hosts = None
            index_url = self.index_url

        # Annoyingly, setuptools will not handle other arguments to
        # Distribution (such as options) before handling setup_requires, so it
        # is not straightforward to programmatically augment the arguments which
        # are passed to easy_install
        class _Distribution(Distribution):
            def get_option_dict(self, command_name):
                opts = Distribution.get_option_dict(self, command_name)
                if command_name == 'easy_install':
                    if find_links is not None:
                        opts['find_links'] = ('setup script', find_links)
                    if index_url is not None:
                        opts['index_url'] = ('setup script', index_url)
                    if allow_hosts is not None:
                        opts['allow_hosts'] = ('setup script', allow_hosts)
                return opts

        if version:
            req = '{0}=={1}'.format(DIST_NAME, version)
        else:
            req = DIST_NAME

        attrs = {'setup_requires': [req]}

        try:
            if DEBUG:
                _Distribution(attrs=attrs)
            else:
                with _silence():
                    _Distribution(attrs=attrs)

            # If the setup_requires succeeded it will have added the new dist to
            # the main working_set
            return pkg_resources.working_set.by_key.get(DIST_NAME)
        except Exception as e:
            if DEBUG:
                raise

            msg = 'Error retrieving {0} from {1}:\n{2}'
            if find_links:
                source = find_links[0]
            elif index_url != INDEX_URL:
                source = index_url
            else:
                source = 'PyPI'

            raise Exception(msg.format(DIST_NAME, source, repr(e))) 
开发者ID:bmorris3,项目名称:whoseline,代码行数:56,代码来源:ah_bootstrap.py


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