conan inspect

警告

此功能处于实验阶段,可能存在重大更改。有关更多信息,请参阅Conan 稳定性部分。

$ conan inspect -h
usage: conan inspect [-h] [-v [V]] [-cc CORE_CONF] [-f FORMAT]
                     [-r REMOTE | -nr] [-l LOCKFILE] [--lockfile-partial]
                     path

Inspect a conanfile.py to return its public fields.

positional arguments:
  path                  Path to a folder containing a recipe (conanfile.py)

options:
  -h, --help            show this help message and exit
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Define core configuration, overwriting global.conf
                        values. E.g.: -cc core:non_interactive=True
  -f FORMAT, --format FORMAT
                        Select the output format: json
  -r REMOTE, --remote REMOTE
                        Remote names. Accepts wildcards ('*' means all the
                        remotes available)
  -nr, --no-remote      Do not use remote, resolve exclusively in the cache
  -l LOCKFILE, --lockfile LOCKFILE
                        Path to a lockfile. Use --lockfile="" to avoid
                        automatic use of existing 'conan.lock' file
  --lockfile-partial    Do not raise an error if some dependency is not found
                        in lockfile

conan inspect 命令显示任何配方(conanfile.py)的公共属性,如下所示

$ conan inspect .
default_options:
    shared: False
    fPIC: True
    neon: True
    msa: True
    sse: True
    vsx: True
    api_prefix:
description: libpng is the official PNG file format reference library.
generators: []
homepage: http://www.libpng.org
label:
license: libpng-2.0
name: libpng
options:
    api_prefix:
    fPIC: True
    msa: True
    neon: True
    shared: False
    sse: True
    vsx: True
options_definitions:
    shared: ['True', 'False']
    fPIC: ['True', 'False']
    neon: ['True', 'check', 'False']
    msa: ['True', 'False']
    sse: ['True', 'False']
    vsx: ['True', 'False']
    api_prefix: ['ANY']
package_type: None
requires: []
revision_mode: hash
settings: ['os', 'arch', 'compiler', 'build_type']
topics: ['png', 'graphics', 'image']
url: https://github.com/conan-io/conan-center-index

conan inspect 会评估配方方法,例如 set_name()set_version(),并且能够解析 python_requires 依赖项(可以使用 --lockfile 参数锁定),因此其基本方法也将正确执行。

注意

--remote 参数仅用于在需要时获取远程 python_requires,**不**用于检查远程的配方。对于此类情况,请使用conan graph info

conan inspect ... --format=json 以 JSON 格式输出到 stdout(可以重定向到文件),结构如下所示

$ conan inspect . --format=json
{
    "name": "libpng",
    "url": "https://github.com/conan-io/conan-center-index",
    "license": "libpng-2.0",
    "description": "libpng is the official PNG file format reference library.",
    "homepage": "http://www.libpng.org",
    "revision_mode": "hash",
    "default_options": {
        "shared": false,
        "fPIC": true,
        "neon": true,
        "msa": true,
        "sse": true,
        "vsx": true,
        "api_prefix": ""
    },
    "topics": [
        "png",
        "graphics",
        "image"
    ],
    "package_type": "None",
    "settings": [
        "os",
        "arch",
        "compiler",
        "build_type"
    ],
    "options": {
        "api_prefix": "",
        "fPIC": "True",
        "msa": "True",
        "neon": "True",
        "shared": "False",
        "sse": "True",
        "vsx": "True"
    },
    "options_definitions": {
        "shared": [
            "True",
            "False"
        ],
        "fPIC": [
            "True",
            "False"
        ],
        "neon": [
            "True",
            "check",
            "False"
        ],
        "msa": [
            "True",
            "False"
        ],
        "sse": [
            "True",
            "False"
        ],
        "vsx": [
            "True",
            "False"
        ],
        "api_prefix": [
            "ANY"
        ]
    },
    "generators": [],
    "requires": [],
    "source_folder": null,
    "build_folder": null,
    "generators_folder": null,
    "package_folder": null,
    "label": ""
}

注意

conan inspect 不会列出 requirements() 方法中列出的任何需求,只会显示 requires 属性中存在的需求。