本文整理汇总了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
示例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 = []
示例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'),
)
)
示例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)
示例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)
示例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
示例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()
示例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)
示例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
示例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)
示例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
示例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 = []
示例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)
示例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)
示例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)