Python pkg_resources.require() Examples
The following are 30
code examples of pkg_resources.require().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pkg_resources
, or try the search function
.
Example #1
Source File: core.py From aws-service-catalog-puppet with Apache License 2.0 | 6 votes |
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'), ) )
Example #2
Source File: dist.py From ironpython2 with Apache License 2.0 | 6 votes |
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 = []
Example #3
Source File: dist.py From lambda-packs with MIT License | 6 votes |
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 = []
Example #4
Source File: dist.py From anpr with Creative Commons Attribution 4.0 International | 6 votes |
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 = []
Example #5
Source File: test_version_it.py From python-pilosa with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #6
Source File: dist.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
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 = []
Example #7
Source File: helper.py From twtxt with MIT License | 5 votes |
def generate_user_agent(): try: version = pkg_resources.require("twtxt")[0].version except pkg_resources.DistributionNotFound: version = "unknown" conf = click.get_current_context().obj["conf"] if conf.disclose_identity and conf.nick and conf.twturl: user_agent = "twtxt/{version} (+{url}; @{nick})".format( version=version, url=conf.twturl, nick=conf.nick) else: user_agent = "twtxt/{version}".format(version=version) return {"User-Agent": user_agent}
Example #8
Source File: dist.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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)
Example #9
Source File: server.py From nematus with BSD 3-Clause "New" or "Revised" License | 5 votes |
def status(self): """ Reports on the status of this translation server. """ response_data = { 'status': self._status, 'models': self._models, 'version': pkg_resources.require("nematus")[0].version, 'service': 'nematus', } response.content_type = "application/json" return json.dumps(response_data)
Example #10
Source File: ez_setup.py From topical_word_embeddings with MIT License | 5 votes |
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ 'setuptools' in sys.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.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( "The required version of setuptools (>=%s) is not available,\n" "and can't be installed while this script is running. Please\n" "install a more recent version first, using\n" "'easy_install -U setuptools'." "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.DistributionNotFound: return _do_download(version, download_base, to_dir, download_delay)
Example #11
Source File: dist.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
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)
Example #12
Source File: dist.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
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)
Example #13
Source File: dist.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
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)
Example #14
Source File: ez_setup.py From ec2-cost-tools with MIT License | 5 votes |
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)
Example #15
Source File: dist.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def get_command_class(self, command): """Pluggable version of get_command_class()""" if command in self.cmdclass: return self.cmdclass[command] eps = pkg_resources.iter_entry_points('distutils.commands', command) for ep in eps: ep.require(installer=self.fetch_build_egg) self.cmdclass[command] = cmdclass = ep.load() return cmdclass else: return _Distribution.get_command_class(self, command)
Example #16
Source File: dist.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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 = []
Example #17
Source File: ez_setup.py From iAI with MIT License | 5 votes |
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)
Example #18
Source File: core.py From i3-xfce with GNU Lesser General Public License v3.0 | 5 votes |
def parse_args(raw_args): """ Parse arguments """ dirs = os.listdir(os.path.join(ROLESDIR, "install")) # Create main parser parser = argparse.ArgumentParser(prog="i3-xfce", description='i3-xfce-installer.') parser.add_argument("--version", "-v", help="Display version", action='version', version="{}".format(pkg_resources.require("i3-xfce")[0].version)) root_subparsers = parser.add_subparsers(dest="function") # Parser for list command install_parser = root_subparsers.add_parser('install', help='install files') install_parser.add_argument('--parts', '-p', help='Parts to install', action="append", metavar=dirs, type=str, choices=dirs) install_parser.add_argument('--verbose', help='Verbose mode', action='store_true', default=False) install_parser.add_argument('--dryrun', "-d", help='Dry run mode', action='store_true', default=False) # Parser for list command uninstall_parser = root_subparsers.add_parser('uninstall', help='uninstall files') uninstall_parser.add_argument('--parts', '-p', help='Parts to install', action="append", metavar=dirs, type=str, choices=dirs) uninstall_parser.add_argument('--verbose', help='Verbose mode', action='store_true', default=False) uninstall_parser.add_argument('--dryrun', "-d", help='Dry run mode', action='store_true', default=False) res = parser.parse_args(raw_args[1:]) if res.parts is None: res.parts = dirs return res
Example #19
Source File: dist.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #20
Source File: dist.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #21
Source File: dist.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #22
Source File: dist.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
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 = []
Example #23
Source File: ez_setup.py From heralding with GNU General Public License v3.0 | 5 votes |
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)
Example #24
Source File: dist.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
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)
Example #25
Source File: dist.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
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)
Example #26
Source File: dist.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
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)
Example #27
Source File: dist.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
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 = []
Example #28
Source File: dist.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #29
Source File: dist.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #30
Source File: dist.py From ironpython2 with Apache License 2.0 | 5 votes |
def get_command_class(self, command): """Pluggable version of get_command_class()""" if command in self.cmdclass: return self.cmdclass[command] eps = pkg_resources.iter_entry_points('distutils.commands', command) for ep in eps: ep.require(installer=self.fetch_build_egg) self.cmdclass[command] = cmdclass = ep.load() return cmdclass else: return _Distribution.get_command_class(self, command)