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


Python pkg_resources.get_distribution方法代码示例

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


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

示例1: show_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def show_version():
    entries = []

    entries.append('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(sys.version_info))
    version_info = discord.version_info
    entries.append('- discord.py v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
    if version_info.releaselevel != 'final':
        pkg = pkg_resources.get_distribution('discord.py')
        if pkg:
            entries.append('    - discord.py pkg_resources: v{0}'.format(pkg.version))

    entries.append('- aiohttp v{0.__version__}'.format(aiohttp))
    entries.append('- websockets v{0.__version__}'.format(websockets))
    uname = platform.uname()
    entries.append('- system info: {0.system} {0.release} {0.version}'.format(uname))
    print('\n'.join(entries)) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:18,代码来源:__main__.py

示例2: install_package

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def install_package(package, version="upgrade"):
        from sys import executable
        from subprocess import check_call
        result = False
        if version.lower() == "upgrade":
            result = check_call([executable, "-m", "pip", "install", package, "--upgrade", "--user"])
        else:
            from pkg_resources import get_distribution
            current_package_version = None
            try:
                current_package_version = get_distribution(package)
            except Exception:
                pass
            if current_package_version is None or current_package_version != version:
                installation_sign = "==" if ">=" not in version else ""
                result = check_call([executable, "-m", "pip", "install", package + installation_sign + version, "--user"])
        return result 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:19,代码来源:tb_utility.py

示例3: cli

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def cli(ctx):
    """Check the latest Apio version."""

    current_version = get_distribution('apio').version
    latest_version = get_pypi_latest_version()

    if latest_version is None:
        ctx.exit(1)

    if latest_version == current_version:
        click.secho('You\'re up-to-date!\nApio {} is currently the '
                    'newest version available.'.format(latest_version),
                    fg='green')
    else:
        click.secho('You\'re not updated\nPlease execute '
                    '`pip install -U apio` to upgrade.',
                    fg="yellow") 
开发者ID:FPGAwars,项目名称:apio,代码行数:19,代码来源:upgrade.py

示例4: install_scripts

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def install_scripts(distributions):
    """
    Regenerate the entry_points console_scripts for the named distribution.
    """
    try:
        from setuptools.command import easy_install
        import pkg_resources
    except ImportError:
        raise RuntimeError("'wheel install_scripts' needs setuptools.")

    for dist in distributions:
        pkg_resources_dist = pkg_resources.get_distribution(dist)
        install = wheel.paths.get_install_command(dist)
        command = easy_install.easy_install(install.distribution)
        command.args = ['wheel'] # dummy argument
        command.finalize_options()
        command.install_egg_scripts(pkg_resources_dist) 
开发者ID:jpush,项目名称:jbox,代码行数:19,代码来源:__init__.py

示例5: create_parent_parser

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

示例6: install_scripts

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def install_scripts(distributions):
    """
    Regenerate the entry_points console_scripts for the named distribution.
    """
    try:
        from setuptools.command import easy_install
        import pkg_resources
    except ImportError:
        raise RuntimeError("'wheel install_scripts' needs setuptools.")

    for dist in distributions:
        pkg_resources_dist = pkg_resources.get_distribution(dist)
        install = get_install_command(dist)
        command = easy_install.easy_install(install.distribution)
        command.args = ['wheel'] # dummy argument
        command.finalize_options()
        command.install_egg_scripts(pkg_resources_dist) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:19,代码来源:__init__.py

示例7: _get_info

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def _get_info(name):
    metadata = _get_metadata(name)
    version = pkg_resources.get_distribution(name).version
    if metadata:
        if metadata['is_release']:
            released = 'released'
        else:
            released = 'pre-release'
        sha = metadata['git_version']
    else:
        version_parts = version.split('.')
        if version_parts[-1].startswith('g'):
            sha = version_parts[-1][1:]
            released = 'pre-release'
        else:
            sha = ""
            released = "released"
            for part in version_parts:
                if not part.isdigit():
                    released = "pre-release"
    return dict(name=name, version=version, sha=sha, released=released) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:23,代码来源:main.py

示例8: send_usage_stats

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def send_usage_stats():
    try:
        version = pkg_resources.get_distribution('target-csv').version
        conn = http.client.HTTPConnection('collector.singer.io', timeout=10)
        conn.connect()
        params = {
            'e': 'se',
            'aid': 'singer',
            'se_ca': 'target-csv',
            'se_ac': 'open',
            'se_la': version,
        }
        conn.request('GET', '/i?' + urllib.parse.urlencode(params))
        response = conn.getresponse()
        conn.close()
    except:
        logger.debug('Collection request failed') 
开发者ID:singer-io,项目名称:target-csv,代码行数:19,代码来源:target_csv.py

示例9: get_mlperf_log

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def get_mlperf_log():
  """Shielded import of mlperf_log module."""
  try:
    import mlperf_compliance

    def test_mlperf_log_pip_version():
      """Check that mlperf_compliance is up to date."""
      import pkg_resources
      version = pkg_resources.get_distribution("mlperf_compliance")
      version = tuple(int(i) for i in version.version.split("."))
      if version < _MIN_VERSION:
        tf.compat.v1.logging.warning(
            "mlperf_compliance is version {}, must be >= {}".format(
                ".".join([str(i) for i in version]),
                ".".join([str(i) for i in _MIN_VERSION])))
        raise ImportError
      return mlperf_compliance.mlperf_log

    mlperf_log = test_mlperf_log_pip_version()

  except ImportError:
    mlperf_log = None

  return mlperf_log 
开发者ID:IntelAI,项目名称:models,代码行数:26,代码来源:mlperf_helper.py

示例10: main

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def main():
    arguments = docopt(
        __doc__,
        version="gdparse {}".format(
            pkg_resources.get_distribution("gdtoolkit").version
        ),
    )

    if not isinstance(arguments, dict):
        print(arguments)
        sys.exit(0)

    for file_path in arguments["<file>"]:
        with open(file_path, "r") as fh:  # TODO: handle exception
            content = fh.read()
            tree = parser.parse(content)  # TODO: handle exception
            if arguments["--pretty"]:
                print(tree.pretty())
            elif arguments["--verbose"]:
                print(tree) 
开发者ID:Scony,项目名称:godot-gdscript-toolkit,代码行数:22,代码来源:__main__.py

示例11: _get_version_info

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

示例12: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def __init__(self, args):
        try:
            print("gurux_dlms version: " + pkg_resources.get_distribution("gurux_dlms").version)
            print("gurux_net version: " + pkg_resources.get_distribution("gurux_net").version)
            print("gurux_serial version: " + pkg_resources.get_distribution("gurux_serial").version)
        except Exception:
            #It's OK if this fails.
            print("pkg_resources not found")
        settings = GXSettings()
        ret = settings.getParameters(args)
        if ret != 0:
            return

        #There might be several notify messages in GBT.
        self.notify = GXReplyData()
        self.client = settings.client
        self.translator = GXDLMSTranslator()
        self.reply = GXByteBuffer()
        settings.media.trace = settings.trace
        print(settings.media)

        #Start to listen events from the media.
        settings.media.addListener(self)
        #Set EOP for the media.
        if settings.client.interfaceType == InterfaceType.HDLC:
            settings.media.eop = 0x7e
        try:
            print("Press any key to close the application.")
            #Open the connection.
            settings.media.open()
            #Wait input.
            input()
            print("Closing")
        except (KeyboardInterrupt, SystemExit, Exception) as ex:
            print(ex)
        settings.media.close()
        settings.media.removeListener(self) 
开发者ID:Gurux,项目名称:Gurux.DLMS.Python,代码行数:39,代码来源:main.py

示例13: getPackageVersion

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def getPackageVersion(name):
    """
    Get a python package version.

    Returns: a string or None
    """
    try:
        pkg = pkg_resources.get_distribution(name)
        return pkg.version
    except:
        return None 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:13,代码来源:system_info.py

示例14: check_plugin_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def check_plugin_version(handler: APIHandler):
    server_extension_version = pkg_resources.get_distribution(
        "jupyterlab_code_formatter"
    ).version
    lab_extension_version = handler.request.headers.get("Plugin-Version")
    version_matches = server_extension_version == lab_extension_version
    if not version_matches:
        handler.set_status(
            422,
            f"Mismatched versions of server extension ({server_extension_version}) "
            f"and lab extension ({lab_extension_version}). "
            f"Please ensure they are the same.",
        )
        handler.finish()
    return version_matches 
开发者ID:ryantam626,项目名称:jupyterlab_code_formatter,代码行数:17,代码来源:handlers.py

示例15: get

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_distribution [as 别名]
def get(self) -> None:
        """Show what version is this server plguin on."""
        self.finish(
            json.dumps(
                {
                    "version": pkg_resources.get_distribution(
                        "jupyterlab_code_formatter"
                    ).version
                }
            )
        ) 
开发者ID:ryantam626,项目名称:jupyterlab_code_formatter,代码行数:13,代码来源:handlers.py


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