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


Python pkg_resources.DistributionNotFound方法代码示例

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


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

示例1: tests_flatten_egginfo_json_missing_deps

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def tests_flatten_egginfo_json_missing_deps(self):
        """
        Missing dependencies should not cause a hard failure.
        """

        make_dummy_dist(self, (
            ('requires.txt', '\n'.join([
                'uilib>=1.0',
            ])),
        ), 'app', '2.0')

        working_set = pkg_resources.WorkingSet([self._calmjs_testing_tmpdir])

        # Python dependency acquisition failures should fail hard.
        with self.assertRaises(pkg_resources.DistributionNotFound):
            calmjs_dist.flatten_egginfo_json(['app'], working_set=working_set) 
开发者ID:calmjs,项目名称:calmjs,代码行数:18,代码来源:test_dist.py

示例2: register_entrypoints

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def register_entrypoints(self):
        """Look through the `setup_tools` `entry_points` and load all of
           the formats.
        """
        for spec in iter_entry_points(self.entry_point_group):
            format_properties = {"name": spec.name}
            try:
                format_properties.update(spec.load())
            except (DistributionNotFound, ImportError) as err:
                self.log.info(
                    "ipymd format {} could not be loaded: {}".format(
                        spec.name, err))
                continue

            self.register(**format_properties)

        return self 
开发者ID:rossant,项目名称:ipymd,代码行数:19,代码来源:format_manager.py

示例3: test_get_version_setup

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [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

示例4: create_parent_parser

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def create_parent_parser(prog_name):
    parent_parser = argparse.ArgumentParser(prog=prog_name, add_help=False)
    parent_parser.add_argument(
        '-v', '--verbose',
        action='count',
        help='enable more verbose output')

    try:
        version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version
    except pkg_resources.DistributionNotFound:
        version = 'UNKNOWN'

    parent_parser.add_argument(
        '-V', '--version',
        action='version',
        version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}')
        .format(version),
        help='display version information')

    return parent_parser 
开发者ID:hyperledger,项目名称:sawtooth-core,代码行数:22,代码来源:main.py

示例5: _get_version_from_pkg_resources

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def _get_version_from_pkg_resources(self):
        """Obtain a version from pkg_resources or setup-time logic if missing.

        This will try to get the version of the package from the pkg_resources
        record associated with the package, and if there is no such record
        falls back to the logic sdist would use.
        """
        try:
            requirement = pkg_resources.Requirement.parse(self.package)
            provider = pkg_resources.get_provider(requirement)
            result_string = provider.version
        except pkg_resources.DistributionNotFound:
            # The most likely cause for this is running tests in a tree
            # produced from a tarball where the package itself has not been
            # installed into anything. Revert to setup-time logic.
            from pbr import packaging
            result_string = packaging.get_version(self.package)
        return SemanticVersion.from_pip_string(result_string) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:20,代码来源:version.py

示例6: _get_version_info

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def _get_version_info(self, modname, all_dist_info):
        try:
            dist_info = pkg_resources.get_distribution(modname)
            return dist_info.project_name, dist_info.version
        except pkg_resources.DistributionNotFound:
            ml = modname.split('.')
            if len(ml) > 1:
                modname = '.'.join(ml[:-1])
                return self._get_version_info(modname, all_dist_info)
            else:
                tmod = modname.split('.')[0]
                x = [
                    (i['project_name'], i['version'])
                    for i in all_dist_info if tmod in i['mods']
                ]
                if x:
                    return x[0]
                else:
                    return _, _ 
开发者ID:crew102,项目名称:reprexpy,代码行数:21,代码来源:session_info.py

示例7: __call__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def __call__(self):
        """Executes the wrapped function and catch common exceptions"""
        try:
            self.function()

        except (IOError, ValueError, OSError,
                RuntimeError, AssertionError) as err:
            self.exit('fatal error: {}'.format(err))

        except pkg_resources.DistributionNotFound:
            self.exit(
                'fatal error: phonemizer package not found\n'
                'please install phonemizer on your system')

        except KeyboardInterrupt:
            self.exit('keyboard interruption, exiting') 
开发者ID:bootphon,项目名称:phonemizer,代码行数:18,代码来源:main.py

示例8: check_requirements

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def check_requirements():
    if sys.version_info < PYTHON_VERSION:
        raise SystemExit('Python version %d.%d required; found %d.%d.'
                         % (PYTHON_VERSION[0], PYTHON_VERSION[1],
                            sys.version_info[0], sys.version_info[1]))

    for package_name, min_version in DEPENDENCIES.items():
        dep_err = False
        try:
            package_version = pkg_resources.require(package_name)[0].version
        except pkg_resources.DistributionNotFound:
            dep_err = True
        else:
            package_version = get_package_version(package_version)

        if not dep_err:
            if min_version > package_version:
                dep_err = True

        if dep_err:
            raise ImportError('`%s` version %d.%d or later required.'
                              % ((package_name, ) + min_version)) 
开发者ID:mscross,项目名称:pysplit,代码行数:24,代码来源:setup.py

示例9: test_returns_default_info_when_given_bad_file_name

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def test_returns_default_info_when_given_bad_file_name(self, mock_dist):
        def not_installed(x):
            raise pkg_resources.DistributionNotFound
        mock_dist.side_effect = not_installed
        info = ciftify.config.ciftify_version('some-file-that-doesnt-exist')

        assert info
        assert self.ciftify_path in info
        assert 'Commit:' in info
        assert 'Last commit for' not in info 
开发者ID:edickie,项目名称:ciftify,代码行数:12,代码来源:test_config.py

示例10: test_returns_default_info_when_no_file_provided

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def test_returns_default_info_when_no_file_provided(self, mock_dist):
        def not_installed(x):
            raise pkg_resources.DistributionNotFound
        mock_dist.side_effect = not_installed
        info = ciftify.config.ciftify_version()

        assert info
        assert self.ciftify_path in info
        assert 'Commit:' in info
        assert 'Last commit for' not in info 
开发者ID:edickie,项目名称:ciftify,代码行数:12,代码来源:test_config.py

示例11: test_returns_path_only_when_git_log_cant_be_found

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def test_returns_path_only_when_git_log_cant_be_found(self, mock_log,
            mock_dist):
        mock_log.return_value = ''
        def not_installed(x):
            raise pkg_resources.DistributionNotFound
        mock_dist.side_effect = not_installed

        info = ciftify.config.ciftify_version()

        assert info
        assert self.ciftify_path in info
        assert "Commit:" not in info 
开发者ID:edickie,项目名称:ciftify,代码行数:14,代码来源:test_config.py

示例12: use_setuptools

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [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

示例13: get_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def get_version():
    try:
        return pkg_resources.get_distribution('apsconnectcli').version
    except pkg_resources.DistributionNotFound:
        return bin_version() 
开发者ID:cloudblue,项目名称:apsconnect-cli,代码行数:7,代码来源:apsconnect.py

示例14: test_get_version_from_package_error

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def test_get_version_from_package_error(self):
        with patch('apsconnectcli.apsconnect.pkg_resources') as pkg_mock, \
                patch('apsconnectcli.apsconnect.bin_version') as bin_mock:
            bin_mock.return_value = 'v100500'
            pkg_mock.DistributionNotFound = DistributionNotFound
            pkg_mock.get_distribution.side_effect = DistributionNotFound()
            result = get_version()

        self.assertEqual(result, 'v100500') 
开发者ID:cloudblue,项目名称:apsconnect-cli,代码行数:11,代码来源:test_apsconnect_internals.py

示例15: distribution_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import DistributionNotFound [as 别名]
def distribution_version(name):
    """try to get the version of the named distribution,
    returs None on failure"""
    from pkg_resources import get_distribution, DistributionNotFound
    try:
        dist = get_distribution(name)
    except DistributionNotFound:
        pass
    else:
        return dist.version 
开发者ID:pytest-dev,项目名称:py,代码行数:12,代码来源:apipkg.py


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