pip inspect JSON 輸出規格¶
加入於版本 22.2。
已於版本 23.0 中變更:version 已升級至 1,且格式已宣告穩定。
pip inspect 指令產生 Python 環境的詳細 JSON 報告,包括已安裝的發行版。
規格¶
報告格式為含有以下屬性的 JSON 物件
version:字串1。僅在下列情況下變更:導入不相容變更時,例如移除必要欄位或變更現有欄位的語義或資料類型。導入不相容變更將遵循 pip 的一般流程,例如棄用循環或功能標記。工具必須檢查此欄位以確保支援相應版本。pip_version:字串,含有用於產生報告的 pip 版本。installed:InspectReportItem陣列,代表已安裝的發行版套件。environment:一個物件,說明產生安裝報告的環境。有關更多資訊,請參閱 相依性規範 規格中的環境標記區段。值具有字串類型。
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的安裝中。注意
REQUESTED的元資料可能不會由所有安裝程式產生。自版本 20.2 開始,pip 會產生這個元資料。installer:INSTALLER元資料的內容(如果存在且不為空)。
範例 ¶
在安裝程式 pip 以可編輯模式安裝,而且同時安裝 packaging 的環境中執行 pip inspect 指令,會產生類似以下的輸出(為簡明起見,摘要元資料)
{
"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 <ptmcg.gm+pyparsing@gmail.com>",
"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": "donald@stufft.io",
"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.python.club.tw/",
"author": "The pip developers",
"author_email": "distutils-sig@python.org",
"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.python.club.tw",
"Source, https://github.com/pypa/pip",
"Changelog, https://pip.python.club.tw/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"
}
}