conan list¶
$ conan list -h
usage: conan list [-h] [-v [V]] [-cc CORE_CONF] [-f FORMAT] [-p PACKAGE_QUERY]
[-fp FILTER_PROFILE] [-fs FILTER_SETTINGS]
[-fo FILTER_OPTIONS] [-r REMOTE] [-c] [-g GRAPH]
[-gb GRAPH_BINARIES] [-gr GRAPH_RECIPES] [--lru LRU]
[pattern]
List existing recipes, revisions, or packages in the cache (by default) or the remotes.
positional arguments:
pattern A pattern in the form
'pkg/version#revision:package_id#revision', e.g:
"zlib/1.2.13:*" means all binaries for zlib/1.2.13. If
revision is not specified, it is assumed latest one.
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, html, compact
-p PACKAGE_QUERY, --package-query PACKAGE_QUERY
List only the packages matching a specific query, e.g,
os=Windows AND (arch=x86 OR compiler=gcc)
-fp FILTER_PROFILE, --filter-profile FILTER_PROFILE
Profiles to filter the binaries
-fs FILTER_SETTINGS, --filter-settings FILTER_SETTINGS
Settings to filter the binaries
-fo FILTER_OPTIONS, --filter-options FILTER_OPTIONS
Options to filter the binaries
-r REMOTE, --remote REMOTE
Remote names. Accepts wildcards ('*' means all the
remotes available)
-c, --cache Search in the local cache
-g GRAPH, --graph GRAPH
Graph json file
-gb GRAPH_BINARIES, --graph-binaries GRAPH_BINARIES
Which binaries are listed
-gr GRAPH_RECIPES, --graph-recipes GRAPH_RECIPES
Which recipes are listed
--lru LRU List recipes and binaries that have not been recently
used. Use a time limit like --lru=5d (days) or
--lru=4w (weeks), h (hours), m(minutes)
conan list
命令可以列出本地缓存、指定远程或两者中的配方和包。此命令使用 *引用模式* 作为输入。此模式的结构基于完整的 Conan 引用,如下所示
name/version@user/channel#rrev:pkgid#prev
此模式支持使用 *
作为通配符以及 #latest
指定最新修订版(尽管在大多数情况下可能没有必要,默认情况下 Conan 将列出最新修订版)。
使用它,您可以列出
配方引用 (
name/version@user/channel
)。配方修订版 (
name/version@user/channel#rrev
)。包 ID 及其配置 (
name/version@user/channel#rrev:pkgids
)。包修订版 (
name/version@user/channel#rrev:pkgids#prev
)。
警告
conan list --format=json
的 json 输出处于 **预览** 状态。有关更多信息,请参阅 Conan 稳定性 部分。
让我们看看如何使用此模式的一些示例
列出配方引用¶
# Make sure to quote the argument
$ conan list "*"
Local Cache
hello
hello/2.26.1@mycompany/testing
hello/2.20.2@mycompany/testing
hello/1.0.4@mycompany/testing
hello/2.3.2@mycompany/stable
hello/1.0.4@mycompany/stable
string-view-lite
string-view-lite/1.6.0
zlib
zlib/1.2.11
$ conan list zlib
Local Cache
zlib
zlib/1.2.11
zlib/1.2.12
正如我们所评论的,您也可以在要搜索的引用中使用 *
通配符。
# Make sure to quote the argument
$ conan list "zlib/*"
Local Cache
zlib
zlib/1.2.11
zlib/1.2.12
您还可以在版本字段中使用版本范围来定义所需的版本
# Make sure to quote the argument
$ conan list "zlib/[<1.2.12]" -r=conancenter
Local Cache
zlib
zlib/1.2.11
$ conan list "zlib/[>1.2.11]" -r=conancenter
Local Cache
zlib
zlib/1.2.12
zlib/1.2.13
使用模式仅搜索匹配特定通道的引用
$ conan list "*/*@*/stable"
Local Cache
hello
hello/2.3.2@mycompany/stable
hello/1.0.4@mycompany/stable
使用 ...@
模式仅搜索没有 *user* 和 *channel* 的引用
$ conan list "*/*@"
Local Cache
string-view-lite
string-view-lite/1.6.0
zlib
zlib/1.2.11
列出配方修订版¶
列出配方的最新配方修订版的简便方法是使用 name/version@user/channel
作为模式
$ conan list zlib/1.2.11
Local Cache
zlib
zlib/1.2.11
revisions
ffa77daf83a57094149707928bdce823 (2022-11-02 13:46:53 UTC)
这等效于明确指定您要使用 #latest
占位符列出最新配方修订版
$ conan list zlib/1.2.11#latest
Local Cache
zlib
zlib/1.2.11
revisions
ffa77daf83a57094149707928bdce823 (2022-11-02 13:46:53 UTC)
要列出所有配方修订版,请使用 *
通配符
$ conan list "zlib/1.2.11#*""
Local Cache
zlib
zlib/1.2.11
revisions
ffa77daf83a57094149707928bdce823 (2022-11-02 13:46:53 UTC)
8b23adc7acd6f1d6e220338a78e3a19e (2022-10-19 09:19:10 UTC)
ce3665ce19f82598aa0f7ac0b71ee966 (2022-10-14 11:42:21 UTC)
31ee767cb2828e539c42913a471e821a (2022-10-12 05:49:39 UTC)
d77ee68739fcbe5bf37b8a4690eea6ea (2022-08-05 17:17:30 UTC)
列出包 ID¶
列出属于最新配方修订版的所有包 ID 的简便方法是使用 name/version@user/channel:*
作为模式
# Make sure to quote the argument
$ conan list "zlib/1.2.11:*"
Local Cache
zlib
zlib/1.2.11
revisions
d77ee68739fcbe5bf37b8a4690eea6ea (2022-08-05 17:17:30 UTC)
packages
d0599452a426a161e02a297c6e0c5070f99b4909
info
settings
arch: x86_64
build_type: Release
compiler: apple-clang
compiler.version: 12.0
os: Macos
options
fPIC: True
shared: False
ebec3dc6d7f6b907b3ada0c3d3cdc83613a2b715
info
settings
arch: x86_64
build_type: Release
compiler: gcc
compiler.version: 11
os: Linux
options
fPIC: True
shared: False
注意
这里配方修订版的 #latest
是隐式的,即该模式等效于 zlib/1.2.11#latest:*
要列出所有配方修订版的所有包 ID,请在修订版 #
部分使用 *
通配符
# Make sure to quote the argument
$ conan list "zlib/1.2.11#*:*"
Local Cache
zlib
zlib/1.2.11
revisions
d77ee68739fcbe5bf37b8a4690eea6ea (2022-08-05 17:17:30 UTC)
packages
d0599452a426a161e02a297c6e0c5070f99b4909
info
settings
arch: x86_64
build_type: Release
compiler: apple-clang
compiler.version: 12.0
os: Macos
options
fPIC: True
shared: False
e4e1703f72ed07c15d73a555ec3a2fa1 (2022-07-04 21:21:45 UTC)
packages
d0599452a426a161e02a297c6e0c5070f99b4909
info
settings
arch: x86_64
build_type: Release
compiler: apple-clang
compiler.version: 12.0
os: Macos
options
fPIC: True
shared: False
列出包修订版¶
列出特定配方修订版和包 ID 的最新包修订版的简便方法是使用模式 name/version@user/channel#rrev:pkgid
$ conan list zlib/1.2.11#8b23adc7acd6f1d6e220338a78e3a19e:fdb823f07bc228621617c6397210a5c6c4c8807b
Local Cache
zlib
zlib/1.2.11
revisions
8b23adc7acd6f1d6e220338a78e3a19e (2022-08-05 17:17:30 UTC)
packages
fdb823f07bc228621617c6397210a5c6c4c8807b
revisions
4834a9b0d050d7cf58c3ab391fe32e25 (2022-11-18 12:33:31 UTC)
要列出最新配方修订版的所有包修订版
# Make sure to quote the argument
$ conan list "zlib/1.2.11:*#*"
Local Cache
zlib
zlib/1.2.11
revisions
6a6451bbfcb0e591333827e9784d7dfa (2022-12-29 11:51:39 UTC)
packages
b1d267f77ddd5d10d06d2ecf5a6bc433fbb7eeed
revisions
67bb089d9d968cbc4ef69e657a03de84 (2022-12-29 11:47:36 UTC)
5e196dbea832f1efee1e70e058a7eead (2022-12-29 11:47:26 UTC)
26475a416fa5b61cb962041623748d73 (2022-12-29 11:02:14 UTC)
d15c4f81b5de757b13ca26b636246edff7bdbf24
revisions
a2eb7f4c8f2243b6e80ec9e7ee0e1b25 (2022-12-29 11:51:40 UTC)
注意
这里配方修订版的 #latest
是隐式的,即该模式等效于 zlib/1.2.11#latest:*#*
列出图形工件¶
当提供 conan list --graph=<graph.json>
图形 json 文件时,该命令将列出其中的二进制文件。默认情况下,它将列出依赖项图形中包含的所有配方和二进制文件。但 --graph-recipes=<recipe-mode>
和 --graph-binaries=<binary-mode>
允许指定最终结果中必须列出哪些工件,一些示例
conan list --graph=graph.json --graph-binaries=build
仅列出已从源代码构建的配方和二进制文件conan list --graph=graph.json --graph-recipes="*"
仅列出配方,所有配方,但不列出二进制文件conan list --graph=graph.json --graph-binaries=download
仅列出在上次conan create
或conan install
中下载的二进制文件
筛选包¶
有几种方法可以筛选命令返回的包
--package-query
选项允许筛选匹配特定查询的包,例如--package-query="os=Windows AND (arch=x86 OR compiler=gcc)"
将仅匹配架构为 x86 或编译器为 gcc 的 Windows 包。您可以按配置文件 (
--filter-profile
)、设置 (--filter-settings
) 或选项 (--filter-options
) 筛选包。请注意,仅考虑配方中声明的设置和选项进行筛选,因此,例如,如果配方未声明shared
选项,则在使用--filter-options="*:shared=True"
筛选器时(无论使用什么shared
值),其包将始终返回
$ conan list "zlib/1.3.1:*" -fs="os=Macos" -fo="*:shared=True" -r=conancenter
conancenter
zlib
zlib/1.3.1
revisions
f52e03ae3d251dec704634230cd806a2 (2024-02-22 09:20:06 UTC)
packages
24612164eb0760405fcd237df0102e554ed1cb2f
info
settings
arch: x86_64
build_type: Release
compiler: apple-clang
compiler.version: 13
os: Macos
options
shared: True
a3c9d80d887539fac38b81ff8cd4585fe42027e0
info
settings
arch: armv8
build_type: Release
compiler: apple-clang
compiler.version: 13
os: Macos
options
shared: True
这两种方法可以一起使用,并且只会列出匹配这两种筛选器的包
列出 json 输出格式¶
注意
最佳实践
终端中的文本输出永远不应该被解析或依赖于自动化,并且仅供人类阅读。对于任何自动化,推荐的方法是使用格式化的输出作为 *json*
conan list ... --format=json
将在 stdout
中返回 json 输出(可以重定向到文件),其结构如下
# Make sure to quote the argument
$ conan list "zlib/1.2.11:*#*" --format=json
{
"Local Cache": {
"zli/1.0.0": {
"revisions": {
"b58eeddfe2fd25ac3a105f72836b3360": {
"timestamp": "2023-01-10 16:30:27 UTC",
"packages": {
"9a4eb3c8701508aa9458b1a73d0633783ecc2270": {
"revisions": {
"d9b1e9044ee265092e81db7028ae10e0": {
"timestamp": "2023-01-10 22:45:49 UTC"
}
},
"info": {
"settings": {
"os": "Linux"
}
}
},
"ebec3dc6d7f6b907b3ada0c3d3cdc83613a2b715": {
"revisions": {
"d9b1e9044ee265092e81db7028ae10e0": {
"timestamp": "2023-01-10 22:45:49 UTC"
}
},
"info": {
"settings": {
"os": "Windows"
}
}
}
}
}
}
}
}
}
列出 html 输出格式¶
conan list ... --format=html
将在 stdout
中返回 html 输出(可以重定向到文件),其结构如下
$ conan list "zlib/1.2.13#*:*#*" --format=html -c > list.html
这是渲染生成的 HTML。
列出紧凑输出格式¶
对于开发人员来说,使用 --format=compact
输出可能很方便,因为它允许将完整引用复制粘贴到其他命令中(例如 conan cache path
)
$ conan list "zlib/1.2.13:*" -r=conancenter --format=compact
conancenter
zlib/1.2.13
zlib/1.2.13#97d5730b529b4224045fe7090592d4c1%1692672717.68 (2023-08-22 02:51:57 UTC)
zlib/1.2.13#97d5730b529b4224045fe7090592d4c1:d62dff20d86436b9c58ddc0162499d197be9de1e
settings: Macos, x86_64, Release, apple-clang, 13
options(diff): fPIC=True, shared=False
zlib/1.2.13#97d5730b529b4224045fe7090592d4c1:abe5e2b04ea92ce2ee91bc9834317dbe66628206
settings: Linux, x86_64, Release, gcc, 11
options(diff): shared=True
zlib/1.2.13#97d5730b529b4224045fe7090592d4c1:ae9eaf478e918e6470fe64a4d8d4d9552b0b3606
settings: Windows, x86_64, Release, msvc, dynamic, Release, 192
options(diff): shared=True
...
--format=compact
将显示 settings
的值列表,并且它将仅显示选项的差异(“diff”),即它将计算所有显示的包的选项的公分母,并且将仅打印与该公分母不同的那些值。