本文整理匯總了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方法的25個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: install_package
點讚 6
# 需要導入模塊: 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,
示例2: show_version
點讚 6
# 需要導入模塊: 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,
示例3: cli
點讚 6
# 需要導入模塊: 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,
示例4: install_scripts
點讚 6
# 需要導入模塊: 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)