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