本文整理汇总了Python中pip._internal方法的典型用法代码示例。如果您正苦于以下问题:Python pip._internal方法的具体用法?Python pip._internal怎么用?Python pip._internal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip
的用法示例。
在下文中一共展示了pip._internal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pip_import_string
# 需要导入模块: import pip [as 别名]
# 或者: from pip import _internal [as 别名]
def pip_import_string():
# type: () -> str
import pip
pip_major_version = int(pip.__version__.split('.')[0])
pip_minor_version = int(pip.__version__.split('.')[1])
pip_major_minor = (pip_major_version, pip_minor_version)
# Pip moved its internals to an _internal module in version 10.
# In order to be compatible with version 9 which has it at at the
# top level we need to figure out the correct import path here.
if (9, 0) <= pip_major_minor < (10, 0):
return 'from pip import main'
elif (10, 0) <= pip_major_minor < (19, 3):
# Pip changed their import structure again in 19.3
# https://github.com/pypa/pip/commit/09fd200
return 'from pip._internal import main'
elif (19, 3) <= pip_major_minor < (20, 0):
return 'from pip._internal.main import main'
elif (20, 0) <= pip_major_minor < (21, 0):
# More changes! https://github.com/pypa/pip/issues/7498
return 'from pip._internal.cli.main import main'
raise RuntimeError("Unknown import string for pip version: %s"
% str(pip_major_minor))
示例2: _run_pip
# 需要导入模块: import pip [as 别名]
# 或者: from pip import _internal [as 别名]
def _run_pip(args, additional_paths=None):
# Add our bundled software to the sys.path so we can import it
if additional_paths is not None:
sys.path = additional_paths + sys.path
# Install the bundled software
import pip._internal
return pip._internal.main(args)
示例3: install_package
# 需要导入模块: import pip [as 别名]
# 或者: from pip import _internal [as 别名]
def install_package(package):
import pip
from pip._internal import main
main.main(['install', package])