非官方的、可导入的api管道

pip-api的Python项目详细描述


由于^{}是命令行工具,it does not have an official, supported, importable API

然而,这并不意味着人们没有尝试import pip,通常 当pip的维护人员进行例行重构时,最终会很头疼。

这个项目试图提供一个可导入的pipapi,它完全是。 使用程序中推荐的pip方法遵从

支持的命令

并非所有版本的pip和所有平台都支持所有命令。 如果您尝试使用的命令不兼容,pip_api将引发 pip_api.exceptions.Incompatible程序要捕获的异常。

所有版本均可用:

  • pip_api.version()

    Returns the pip version as a string, e.g. "9.0.1"

  • pip_api.installed_distributions()

    Returns a list of all installed distributions as a Distribution object with the following attributes:

    • Distribution.name (string): The name of the installed distribution
    • Distribution.version (packaging.version.Version): The version of the installed distribution
    • Distribution.location (string): The location of the installed distribution
    • Distribution.editable (bool): Whether the distribution is editable or not
  • pip_api.parse_requirements(filename, options=None, include_invalid=False)

    Takes a path to a filename of a Requirements file. Returns a mapping from package name to a packaging.requirements.Requirement object with the following attributes:

    • Requirement.name (string): The name of the requirement.
    • Requirement.extras (set): A set of extras that the requirement specifies.
    • Requirement.specifier (packaging.specifiers.SpecifierSet): A SpecifierSet of the version specified by the requirement.
    • Requirement.marker (packaging.markers.Marker): A Marker of the marker for the requirement. Can be None.Optionally takes anoptionsparameter to override the regex used to skip requirements lines. Optionally takes aninclude_invalidparameter to return anUnparsedRequirement` in the event that a requirement cannot be parsed correctly.

pip>=8.0.0

一起提供
  • pip_api.hash(filename, algorithm='sha256')

    Returns the resulting as a string. Valid algorithm parameters are 'sha256', 'sha384', and 'sha512'

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法启动应用程序:JNLP错误   java根据用户输入在PreparedStatement中使用setTime()或setNull()   java EJB与同步   java以object为键通过hashmap进行搜索   java中的模10^9+7   针对包含其他对象的对象的java OOP最佳实践   如何将字符串作为HTML代码从Java文件读取到JSP页面?   java我的POM怎么了?“解析表达式..检测到递归表达式循环”   用于Hbase的Mapreduce的java NoSuchMethodError   JAVAlang.SecurityException:权限拒绝:启动意图{act=安卓.Intent.action.MAIN cat=[安卓.Intent.category.LAUNCHER]   数组初始化谜语Java   通过arraylist搜索时的java句柄关联