當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。