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


Python pkg_resources.require方法代码示例

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


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

示例1: test_get_version_setup

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def test_get_version_setup(self):
        def mock1(*args, **kwargs):
            raise OSError
        try:
            backup1 = subprocess.check_output
        except AttributeError:
            backup1 = None
        subprocess.check_output = mock1
        def mock2(*args, **kwargs):
            raise pkg_resources.DistributionNotFound
        backup2 = pkg_resources.require
        pkg_resources.require = mock2
        try:
            self.assertEquals("0.0.0-unversioned", _get_version_setup())
        finally:
            if backup1:
                subprocess.check_output = backup1
            pkg_resources.require = backup2 
开发者ID:pilosa,项目名称:python-pilosa,代码行数:20,代码来源:test_version_it.py

示例2: finalize_options

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = [] 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:dist.py

示例3: version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def version():
    click.echo("cli version: {}".format(pkg_resources.require("aws-service-catalog-puppet")[0].version))
    with betterboto_client.ClientContextManager('ssm') as ssm:
        response = ssm.get_parameter(
            Name="service-catalog-puppet-regional-version"
        )
        click.echo(
            "regional stack version: {} for region: {}".format(
                response.get('Parameter').get('Value'),
                response.get('Parameter').get('ARN').split(':')[3]
            )
        )
        response = ssm.get_parameter(
            Name="service-catalog-puppet-version"
        )
        click.echo(
            "stack version: {}".format(
                response.get('Parameter').get('Value'),
            )
        ) 
开发者ID:awslabs,项目名称:aws-service-catalog-puppet,代码行数:22,代码来源:core.py

示例4: use_setuptools

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def use_setuptools(
        version=DEFAULT_VERSION, download_base=DEFAULT_URL,
        to_dir=DEFAULT_SAVE_DIR, download_delay=15):
    """
    Ensure that a setuptools version is installed.

    Return None. Raise SystemExit if the requested version
    or later cannot be installed.
    """
    to_dir = os.path.abspath(to_dir)

    # prior to importing, capture the module state for
    # representative modules.
    rep_modules = 'pkg_resources', 'setuptools'
    imported = set(sys.modules).intersection(rep_modules)

    try:
        import pkg_resources
        pkg_resources.require("setuptools>=" + version)
        # a suitable version is already installed
        return
    except ImportError:
        # pkg_resources not available; setuptools is not installed; download
        pass
    except pkg_resources.DistributionNotFound:
        # no version of setuptools was found; allow download
        pass
    except pkg_resources.VersionConflict as VC_err:
        if imported:
            _conflict_bail(VC_err, version)

        # otherwise, unload pkg_resources to allow the downloaded version to
        #  take precedence.
        del pkg_resources
        _unload_pkg_resources()

    return _do_download(version, download_base, to_dir, download_delay) 
开发者ID:aimuch,项目名称:iAI,代码行数:39,代码来源:ez_setup.py

示例5: main

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def main():
    # Parse Options
    parser = argparse.ArgumentParser()

    parser.add_argument('-v', dest='verbosity', action='count', default=0,
                        help='Increase the verbosity of the output (repeat for more verbose output)')
    parser.add_argument('-q', dest='quietness', action='count', default=0,
                        help='Decrease the verbosity of the output (repeat for even less verbose output)')

    parser.add_argument("--version", action='version',
                        version=pkg_resources.require("project_generator_definitions")[0].version, help="Display version")

    subparsers = parser.add_subparsers(help='commands')

    for name, module in subcommands.items():
        subparser = subparsers.add_parser(name, help=module.help)

        module.setup(subparser)
        subparser.set_defaults(func=module.run)

    args = parser.parse_args()

    # set the verbosity
    verbosity = args.verbosity - args.quietness

    logging_level = max(logging.INFO - (10 * verbosity), 0)

    logging.basicConfig(format="%(levelname)s\t%(message)s", level=logging_level)

    return args.func(args) 
开发者ID:project-generator,项目名称:project_generator_definitions,代码行数:32,代码来源:main.py

示例6: is_installed

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def is_installed(requirement):
    try:
        pkg_resources.require(requirement)
    except pkg_resources.ResolutionError:
        return False
    else:
        return True 
开发者ID:jwplayer,项目名称:jwalk,代码行数:9,代码来源:setup.py

示例7: print_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def print_version(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    t = [["name", "version"]]
    for app in ["uptick", "bitshares", "graphenelib"]:
        t.append(
            [
                highlight(pkg_resources.require(app)[0].project_name),
                detail(pkg_resources.require(app)[0].version),
            ]
        )
    print_table(t)
    ctx.exit() 
开发者ID:bitshares,项目名称:uptick,代码行数:15,代码来源:ui.py

示例8: use_setuptools

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
                   to_dir=os.curdir, download_delay=15):
    to_dir = os.path.abspath(to_dir)
    rep_modules = 'pkg_resources', 'setuptools'
    imported = set(sys.modules).intersection(rep_modules)
    try:
        import pkg_resources
    except ImportError:
        return _do_download(version, download_base, to_dir, download_delay)
    try:
        pkg_resources.require("setuptools>=" + version)
        return
    except pkg_resources.DistributionNotFound:
        return _do_download(version, download_base, to_dir, download_delay)
    except pkg_resources.VersionConflict as VC_err:
        if imported:
            msg = textwrap.dedent("""
                The required version of setuptools (>={version}) is not available,
                and can't be installed while this script is running. Please
                install a more recent version first, using
                'easy_install -U setuptools'.

                (Currently using {VC_err.args[0]!r})
                """).format(VC_err=VC_err, version=version)
            sys.stderr.write(msg)
            sys.exit(2)

        # otherwise, reload ok
        del pkg_resources, sys.modules['pkg_resources']
        return _do_download(version, download_base, to_dir, download_delay) 
开发者ID:fangpenlin,项目名称:bugbuzz-python,代码行数:32,代码来源:ez_setup.py

示例9: _installed_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def _installed_version():
    try:
        return pkg_resources.require('pilosa')[0].version
    except pkg_resources.DistributionNotFound:
        return None 
开发者ID:pilosa,项目名称:python-pilosa,代码行数:7,代码来源:version.py

示例10: use_setuptools

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
        to_dir=os.curdir, download_delay=15):
    to_dir = os.path.abspath(to_dir)
    rep_modules = 'pkg_resources', 'setuptools'
    imported = set(sys.modules).intersection(rep_modules)
    try:
        import pkg_resources
    except ImportError:
        return _do_download(version, download_base, to_dir, download_delay)
    try:
        pkg_resources.require("setuptools>=" + version)
        return
    except pkg_resources.DistributionNotFound:
        return _do_download(version, download_base, to_dir, download_delay)
    except pkg_resources.VersionConflict as VC_err:
        if imported:
            msg = textwrap.dedent("""
                The required version of setuptools (>={version}) is not available,
                and can't be installed while this script is running. Please
                install a more recent version first, using
                'easy_install -U setuptools'.

                (Currently using {VC_err.args[0]!r})
                """).format(VC_err=VC_err, version=version)
            sys.stderr.write(msg)
            sys.exit(2)

        # otherwise, reload ok
        del pkg_resources, sys.modules['pkg_resources']
        return _do_download(version, download_base, to_dir, download_delay) 
开发者ID:jeremybmerrill,项目名称:flyover,代码行数:32,代码来源:ez_setup.py

示例11: _create_main_parser

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def _create_main_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-u', '--update-repos',
        action='store_true',
        help="update the repositories before doing any action"
    )
    parser.add_argument(
        '-n', '--no-confirm',
        action='store_true',
        help="Bypass all “Are you sure?” messages"
    )
    parser.add_argument(
        '-f', '--force',
        action='store_true',
        help="Continue performing the action even if hooks functions fail"
    )
    parser.add_argument(
        '-c', '--config-file', metavar='FILE', type=Path,
        default=None,
        help="location of the pearl config path. Defaults to $HOME/.config/pearl/pearl.conf"
    )
    parser.add_argument(
        '--verbose', '-v', action='count', default=0,
        help="-v increases output verbosity. "
             "-vv shows bash xtrace during the hook function execution."
    )
    version = pkg_resources.require("pearl")[0].version
    parser.add_argument('--version', '-V', action='version', version='%(prog)s {}'.format(version))
    return parser 
开发者ID:pearl-core,项目名称:pearl,代码行数:32,代码来源:parser.py

示例12: finalize_options

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self,ep.name,None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [os.path.abspath(p) for p in self.convert_2to3_doctests]
        else:
            self.convert_2to3_doctests = [] 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:dist.py

示例13: get_command_class

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands',command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command) 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:dist.py

示例14: print_commands

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def print_commands(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.print_commands(self) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:dist.py

示例15: get_command_list

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import require [as 别名]
def get_command_list(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.get_command_list(self) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:dist.py


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