pip inspect JSON出力仕様

バージョン22.2で追加。

バージョン23.0で変更: version1に更新され、フォーマットは安定版として宣言されました。

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: 使用された場合、direct URLデータ構造を使用したインストールに使用されたdirect 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.dokyumento.jp/",
        "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.dokyumento.jp",
          "Source, https://github.com/pypa/pip",
          "Changelog, https://pip.dokyumento.jp/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"
  }
}