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