非官方的、可导入的api管道
pip-api的Python项目详细描述
由于^{
然而,这并不意味着人们没有尝试import pip
,通常
当pip
的维护人员进行例行重构时,最终会很头疼。
这个项目试图提供一个可导入的pip
api,它完全是。
使用程序中推荐的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 distributionDistribution.version
(packaging.version.Version
): The version of the installed distributionDistribution.location
(string
): The location of the installed distributionDistribution.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
): ASpecifierSet
of the version specified by the requirement.Requirement.marker
(packaging.markers.Marker
): AMarker
of the marker for the requirement. Can be None.Optionally takes an
optionsparameter to override the regex used to skip requirements lines. Optionally takes an
include_invalidparameter to return an
UnparsedRequirement` 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'