|
| 1 | +# `pip inspect` JSON output specification |
| 2 | + |
| 3 | +```{versionadded} 22.2 |
| 4 | +``` |
| 5 | + |
| 6 | +The `pip inspect` command produces a detailed JSON report of the Python |
| 7 | +environment, including installed distributions. |
| 8 | + |
| 9 | +## Specification |
| 10 | + |
| 11 | +The report is a JSON object with the following properties: |
| 12 | + |
| 13 | +- `version`: the string `0`, denoting that the inspect command is an experimental |
| 14 | + feature. This value will change to `1`, when the feature is deemed stable after |
| 15 | + gathering user feedback (likely in pip 22.3 or 23.0). Backward incompatible changes |
| 16 | + may be introduced in version `1` without notice. After that, it will change only if |
| 17 | + and when backward incompatible changes are introduced, such as removing mandatory |
| 18 | + fields or changing the semantics or data type of existing fields. The introduction of |
| 19 | + backward incompatible changes will follow the usual pip processes such as the |
| 20 | + deprecation cycle or feature flags. Tools must check this field to ensure they support |
| 21 | + the corresponding version. |
| 22 | + |
| 23 | +- `pip_version`: a string with the version of pip used to produce the report. |
| 24 | + |
| 25 | +- `installed`: an array of [InspectReportItem](InspectReportItem) representing the |
| 26 | + distribution packages that are installed. |
| 27 | + |
| 28 | +- `environment`: an object describing the environment where the installation report was |
| 29 | + generated. See [PEP 508 environment |
| 30 | + markers](https://peps.python.org/pep-0508/#environment-markers) for more information. |
| 31 | + Values have a string type. |
| 32 | + |
| 33 | +(InspectReportItem)= |
| 34 | + |
| 35 | +An `InspectReportItem` is an object describing an installed distribution package with |
| 36 | +the following properties: |
| 37 | + |
| 38 | +- `metadata`: the metadata of the distribution, converted to a JSON object according to |
| 39 | + the [PEP 566 |
| 40 | + transformation](https://www.python.org/dev/peps/pep-0566/#json-compatible-metadata). |
| 41 | + |
| 42 | +- `metadata_location`: the location of the metadata of the installed distribution. Most |
| 43 | + of the time this is the `.dist-info` directory. For legacy installs it is the |
| 44 | + `.egg-info` directory. |
| 45 | + |
| 46 | + ```{warning} |
| 47 | + This field may not necessary point to a directory, for instance, in the case of older |
| 48 | + `.egg` installs. |
| 49 | + ``` |
| 50 | + |
| 51 | +- `direct_url`: Information about the direct URL that was used for installation, if any, |
| 52 | + using the [direct |
| 53 | + URL](https://packaging.python.org/en/latest/specifications/direct-url/) data |
| 54 | + structure. In most case, this field corresponds to the `direct_url.json` metadata, |
| 55 | + except for legacy editable installs, where it is emulated. |
| 56 | + |
| 57 | +- `requested`: `true` if the `REQUESTED` metadata is present, `false` otherwise. This |
| 58 | + field is only present for modern `.dist-info` installations. |
| 59 | + |
| 60 | + ```{note} |
| 61 | + The `REQUESTED` metadata may not be generated by all installers. |
| 62 | + It is generated by pip since version 20.2. |
| 63 | + ``` |
| 64 | + |
| 65 | +- `installer`: the content of the `INSTALLER` metadata, if present and not empty. |
| 66 | + |
| 67 | +## Example |
| 68 | + |
| 69 | +Running the ``pip inspect`` command, in an environment where `pip` is installed in |
| 70 | +editable mode and `packaging` is installed as well, will produce an output similar to |
| 71 | +this (metadata abriged for brevity): |
| 72 | + |
| 73 | +```json |
| 74 | +{ |
| 75 | + "version": "0", |
| 76 | + "pip_version": "22.2.dev0", |
| 77 | + "installed": [ |
| 78 | + { |
| 79 | + "metadata": { |
| 80 | + "metadata_version": "2.1", |
| 81 | + "name": "pyparsing", |
| 82 | + "version": "3.0.9", |
| 83 | + "summary": "pyparsing module - Classes and methods to define and execute parsing grammars", |
| 84 | + "description_content_type": "text/x-rst", |
| 85 | + "author_email": "Paul McGuire <[email protected]>", |
| 86 | + "classifier": [ |
| 87 | + "Development Status :: 5 - Production/Stable", |
| 88 | + "Intended Audience :: Developers", |
| 89 | + "Intended Audience :: Information Technology", |
| 90 | + "License :: OSI Approved :: MIT License", |
| 91 | + "Operating System :: OS Independent", |
| 92 | + "Programming Language :: Python", |
| 93 | + "Programming Language :: Python :: 3", |
| 94 | + "Programming Language :: Python :: 3.6", |
| 95 | + "Programming Language :: Python :: 3.7", |
| 96 | + "Programming Language :: Python :: 3.8", |
| 97 | + "Programming Language :: Python :: 3.9", |
| 98 | + "Programming Language :: Python :: 3.10", |
| 99 | + "Programming Language :: Python :: 3 :: Only", |
| 100 | + "Programming Language :: Python :: Implementation :: CPython", |
| 101 | + "Programming Language :: Python :: Implementation :: PyPy", |
| 102 | + "Typing :: Typed" |
| 103 | + ], |
| 104 | + "requires_dist": [ |
| 105 | + "railroad-diagrams ; extra == \"diagrams\"", |
| 106 | + "jinja2 ; extra == \"diagrams\"" |
| 107 | + ], |
| 108 | + "requires_python": ">=3.6.8", |
| 109 | + "project_url": [ |
| 110 | + "Homepage, https://github.com/pyparsing/pyparsing/" |
| 111 | + ], |
| 112 | + "provides_extra": [ |
| 113 | + "diagrams" |
| 114 | + ], |
| 115 | + "description": "..." |
| 116 | + }, |
| 117 | + "metadata_location": "/home/me/.virtualenvs/demoenv/lib/python3.8/site-packages/pyparsing-3.0.9.dist-info", |
| 118 | + "installer": "pip", |
| 119 | + "requested": false |
| 120 | + }, |
| 121 | + { |
| 122 | + "metadata": { |
| 123 | + "metadata_version": "2.1", |
| 124 | + "name": "packaging", |
| 125 | + "version": "21.3", |
| 126 | + "platform": [ |
| 127 | + "UNKNOWN" |
| 128 | + ], |
| 129 | + "summary": "Core utilities for Python packages", |
| 130 | + "description_content_type": "text/x-rst", |
| 131 | + "home_page": "https://github.com/pypa/packaging", |
| 132 | + "author": "Donald Stufft and individual contributors", |
| 133 | + "author_email": "[email protected]", |
| 134 | + "license": "BSD-2-Clause or Apache-2.0", |
| 135 | + "classifier": [ |
| 136 | + "Development Status :: 5 - Production/Stable", |
| 137 | + "Intended Audience :: Developers", |
| 138 | + "License :: OSI Approved :: Apache Software License", |
| 139 | + "License :: OSI Approved :: BSD License", |
| 140 | + "Programming Language :: Python", |
| 141 | + "Programming Language :: Python :: 3", |
| 142 | + "Programming Language :: Python :: 3 :: Only", |
| 143 | + "Programming Language :: Python :: 3.6", |
| 144 | + "Programming Language :: Python :: 3.7", |
| 145 | + "Programming Language :: Python :: 3.8", |
| 146 | + "Programming Language :: Python :: 3.9", |
| 147 | + "Programming Language :: Python :: 3.10", |
| 148 | + "Programming Language :: Python :: Implementation :: CPython", |
| 149 | + "Programming Language :: Python :: Implementation :: PyPy" |
| 150 | + ], |
| 151 | + "requires_dist": [ |
| 152 | + "pyparsing (!=3.0.5,>=2.0.2)" |
| 153 | + ], |
| 154 | + "requires_python": ">=3.6", |
| 155 | + "description": "..." |
| 156 | + }, |
| 157 | + "metadata_location": "/home/me/.virtualenvs/demoenv/lib/python3.8/site-packages/packaging-21.3.dist-info", |
| 158 | + "installer": "pip", |
| 159 | + "requested": true |
| 160 | + }, |
| 161 | + { |
| 162 | + "metadata": { |
| 163 | + "metadata_version": "2.1", |
| 164 | + "name": "pip", |
| 165 | + "version": "22.2.dev0", |
| 166 | + "summary": "The PyPA recommended tool for installing Python packages.", |
| 167 | + "home_page": "https://pip.pypa.io/", |
| 168 | + "author": "The pip developers", |
| 169 | + "author_email": "[email protected]", |
| 170 | + "license": "MIT", |
| 171 | + "classifier": [ |
| 172 | + "Development Status :: 5 - Production/Stable", |
| 173 | + "Intended Audience :: Developers", |
| 174 | + "License :: OSI Approved :: MIT License", |
| 175 | + "Topic :: Software Development :: Build Tools", |
| 176 | + "Programming Language :: Python", |
| 177 | + "Programming Language :: Python :: 3", |
| 178 | + "Programming Language :: Python :: 3 :: Only", |
| 179 | + "Programming Language :: Python :: 3.7", |
| 180 | + "Programming Language :: Python :: 3.8", |
| 181 | + "Programming Language :: Python :: 3.9", |
| 182 | + "Programming Language :: Python :: 3.10", |
| 183 | + "Programming Language :: Python :: Implementation :: CPython", |
| 184 | + "Programming Language :: Python :: Implementation :: PyPy" |
| 185 | + ], |
| 186 | + "requires_python": ">=3.7", |
| 187 | + "project_url": [ |
| 188 | + "Documentation, https://pip.pypa.io", |
| 189 | + "Source, https://github.com/pypa/pip", |
| 190 | + "Changelog, https://pip.pypa.io/en/stable/news/" |
| 191 | + ], |
| 192 | + "description": "..." |
| 193 | + }, |
| 194 | + "metadata_location": "/home/me/pip/src/pip.egg-info", |
| 195 | + "direct_url": { |
| 196 | + "url": "file:///home/me/pip/src", |
| 197 | + "dir_info": { |
| 198 | + "editable": true |
| 199 | + } |
| 200 | + } |
| 201 | + } |
| 202 | + ], |
| 203 | + "environment": { |
| 204 | + "implementation_name": "cpython", |
| 205 | + "implementation_version": "3.8.10", |
| 206 | + "os_name": "posix", |
| 207 | + "platform_machine": "x86_64", |
| 208 | + "platform_release": "5.13-generic", |
| 209 | + "platform_system": "Linux", |
| 210 | + "platform_version": "...", |
| 211 | + "python_full_version": "3.8.10", |
| 212 | + "platform_python_implementation": "CPython", |
| 213 | + "python_version": "3.8", |
| 214 | + "sys_platform": "linux" |
| 215 | + } |
| 216 | +} |
| 217 | +``` |
0 commit comments