pip inspect
JSON 输出规范¶
在版本 22.2 中添加。
在版本 23.0 中更改: version
已升级至 1
,格式已声明为稳定。
The pip inspect
命令生成 Python 环境的详细 JSON 报告,包括已安装的发行版。
规范¶
该报告是一个 JSON 对象,具有以下属性
version
: 字符串1
。它只会在引入向后不兼容的更改时才会更改,例如删除必填字段或更改现有字段的语义或数据类型。引入向后不兼容的更改将遵循 pip 的通常流程,例如弃用周期或功能标志。工具必须检查此字段以确保它们支持相应的版本。pip_version
: 一个字符串,包含用于生成报告的 pip 版本。installed
: 一个InspectReportItem
数组,代表已安装的发行版包。environment
: 一个对象,描述生成安装报告的环境。有关更多信息,请参见 Dependency specifiers 规范中的环境标记部分。值具有字符串类型。
一个 InspectReportItem
是一个描述已安装发行版包的对象,具有以下属性
metadata
: 发行版的元数据,根据 PEP 566 转换 转换为 JSON 对象。metadata_location
: 已安装发行版元数据的所在位置。大多数情况下,这是.dist-info
目录。对于旧版安装,它是.egg-info
目录。警告
此字段不一定指向目录,例如,在较旧的
.egg
安装的情况下。direct_url
: 关于用于安装的直接 URL 的信息,如果有,使用 直接 URL 数据结构。在大多数情况下,此字段对应于direct_url.json
元数据,除了旧版可编辑安装,它是在模拟的。requested
: 如果存在REQUESTED
元数据,则为true
,否则为false
。此字段仅在现代.dist-info
安装中存在。注意
The
REQUESTED
元数据可能不会由所有安装程序生成。它是由 pip 从版本 20.2 开始生成的。installer
: 如果存在且不为空,则为INSTALLER
元数据的內容。
示例¶
运行 pip inspect
命令,在一个 pip
以可编辑模式安装,而 packaging
也已安装的环境中,将生成类似于以下输出(元数据为简洁起见而缩写)
{
"version": "1",
"pip_version": "22.2.dev0",
"installed": [
{
"metadata": {
"metadata_version": "2.1",
"name": "pyparsing",
"version": "3.0.9",
"summary": "pyparsing module - Classes and methods to define and execute parsing grammars",
"description_content_type": "text/x-rst",
"author_email": "Paul McGuire <[email protected]>",
"classifier": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Typing :: Typed"
],
"requires_dist": [
"railroad-diagrams ; extra == \"diagrams\"",
"jinja2 ; extra == \"diagrams\""
],
"requires_python": ">=3.6.8",
"project_url": [
"Homepage, https://github.com/pyparsing/pyparsing/"
],
"provides_extra": [
"diagrams"
],
"description": "..."
},
"metadata_location": "/home/me/.virtualenvs/demoenv/lib/python3.8/site-packages/pyparsing-3.0.9.dist-info",
"installer": "pip",
"requested": false
},
{
"metadata": {
"metadata_version": "2.1",
"name": "packaging",
"version": "21.3",
"platform": [
"UNKNOWN"
],
"summary": "Core utilities for Python packages",
"description_content_type": "text/x-rst",
"home_page": "https://github.com/pypa/packaging",
"author": "Donald Stufft and individual contributors",
"author_email": "[email protected]",
"license": "BSD-2-Clause or Apache-2.0",
"classifier": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
],
"requires_dist": [
"pyparsing (!=3.0.5,>=2.0.2)"
],
"requires_python": ">=3.6",
"description": "..."
},
"metadata_location": "/home/me/.virtualenvs/demoenv/lib/python3.8/site-packages/packaging-21.3.dist-info",
"installer": "pip",
"requested": true
},
{
"metadata": {
"metadata_version": "2.1",
"name": "pip",
"version": "22.2.dev0",
"summary": "The PyPA recommended tool for installing Python packages.",
"home_page": "https://pip.pythonlang.cn/",
"author": "The pip developers",
"author_email": "[email protected]",
"license": "MIT",
"classifier": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
],
"requires_python": ">=3.7",
"project_url": [
"Documentation, https://pip.pythonlang.cn",
"Source, https://github.com/pypa/pip",
"Changelog, https://pip.pythonlang.cn/en/stable/news/"
],
"description": "..."
},
"metadata_location": "/home/me/pip/src/pip.egg-info",
"direct_url": {
"url": "file:///home/me/pip/src",
"dir_info": {
"editable": true
}
}
}
],
"environment": {
"implementation_name": "cpython",
"implementation_version": "3.8.10",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "5.13-generic",
"platform_system": "Linux",
"platform_version": "...",
"python_full_version": "3.8.10",
"platform_python_implementation": "CPython",
"python_version": "3.8",
"sys_platform": "linux"
}
}