当前位置: 首页>>代码示例>>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方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_build_egg

# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import get_option_dict [as 别名]
	def fetch_build_egg(self, req):
		""" Specialized version of Distribution.fetch_build_egg
		that respects respects allow_hosts and index_url. """
		from setuptools.command.easy_install import easy_install
		dist = Distribution({'script_args': ['easy_install']})
		dist.parse_config_files()
		opts = dist.get_option_dict('easy_install')
		keep = (
			'find_links', 'site_dirs', 'index_url', 'optimize',
			'site_dirs', 'allow_hosts'
		)
		for key in list(opts):
			if key not in keep:
				del opts[key]  # don't use any other settings
		if self.dependency_links:
			links = self.dependency_links[:]
			if 'find_links' in opts:
				links = opts['find_links'][1].split() + links
			opts['find_links'] = ('setup', links)
		if self.allow_hosts:
			opts['allow_hosts'] = ('test', self.allow_hosts)
		if self.index_url:
			opts['index_url'] = ('test', self.index_url)
		install_dir_func = getattr(self, 'get_egg_cache_dir', _os.getcwd)
		install_dir = install_dir_func()
		cmd = easy_install(
			dist, args=["x"], install_dir=install_dir,
			exclude_scripts=True,
			always_copy=False, build_directory=None, editable=False,
			upgrade=False, multi_version=True, no_report=True, user=False
		)
		cmd.ensure_finalized()
		return cmd.easy_install(req)
开发者ID:blue-yonder,项目名称:pyscaffold,代码行数:35,代码来源:ptr.py

示例2: get_option_dict

# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import get_option_dict [as 别名]
 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
开发者ID:astrofrog,项目名称:sphere,代码行数:12,代码来源:ah_bootstrap.py

示例3: main

# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import get_option_dict [as 别名]
def main(argv=None, **kw):
    """ Run a test package's tests.
    """
    # TODO: allow cmdline override of org config?
    config.setup_org_config()

    from path import path

    USAGE = """\
usage: %(script)s <package name> [test options]
   or: %(script)s --help
""" % {'script': sys.argv[0] or 'runtests'}

    if argv is None:
        argv = sys.argv[1:]

    if not argv:
        print "Please specify a package name."
        print USAGE
        sys.exit(1)

    pkg_name, argv = argv[0], argv[1:]
    test_pkg_name = 'test.%s' % pkg_name

    # Find our
    real_dist = [i for i in working_set if i.project_name == pkg_name]
    if not real_dist:
        print "Package %s is not installed" % pkg_name
        sys.exit(1)
    real_dist = real_dist[0]

    test_dist = [i for i in working_set if i.project_name == test_pkg_name]
    if not test_dist:
        print "Test package %s is not installed" % test_pkg_name
        sys.exit(1)
    test_dist = test_dist[0]

    # Construct a distutils.Distribtion class from the pkg_resources.Distribution
    # of the real package so we can pass it into the test command class.
    # We have checked that the packages are already installed so we set the install
    # requirements to blank.

    args = {'name': real_dist.project_name,
            'install_requires': [],
            'tests_require': [],
            'namespace_packages': list(real_dist._get_metadata('namespace_packages')),
            'packages': [real_dist.project_name],
            }
    real_cmd_dist = Distribution(args)
    cmd = test(real_cmd_dist)
    cmd.args = argv

    # Read in the test options saved away during egg_info and set the command defaults,
    # this would normally be done by the setup() method via the Distribution class
    test_options = path(test_dist.location) / 'EGG-INFO' / 'test_options.txt'
    if test_options.isfile():
        real_cmd_dist.parse_config_files([test_options])
    for k, v in real_cmd_dist.get_option_dict('test').items():
        print "Found test option in %s: %s = %s" % (v[0], k, v[1])
        setattr(cmd, k, v[1])

    # Finalize and run the command, overriding the test root to be inside the test egg
    cmd.finalize_options()
    cmd.test_root = path(test_dist.location) / CONFIG.test_egg_namespace / \
                         real_dist.project_name.replace('.', '/')
    # Pylint is only for regular Jenkins jobs, this in itself should not trigger even if
    # running under Jenkins
    cmd.no_pylint = True
    cmd.run()
开发者ID:NunoEdgarGub1,项目名称:pkglib,代码行数:71,代码来源:runtests.py


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