conan export-pkg

$ conan export-pkg -h
usage: conan export-pkg [-h] [-f FORMAT] [--out-file OUT_FILE]
                        [-v [{quiet,error,warning,notice,status,,verbose,debug,v,trace,vv}]]
                        [-cc CORE_CONF] [-of OUTPUT_FOLDER] [--build-require]
                        [-tf TEST_FOLDER] [-sb] [-r REMOTE | -nr]
                        [--name NAME] [--version VERSION] [--user USER]
                        [--channel CHANNEL] [-l LOCKFILE] [--lockfile-partial]
                        [--lockfile-out LOCKFILE_OUT] [--lockfile-clean]
                        [--lockfile-overrides LOCKFILE_OVERRIDES]
                        [-pr PROFILE] [-pr:b PROFILE_BUILD]
                        [-pr:h PROFILE_HOST] [-pr:a PROFILE_ALL] [-o OPTIONS]
                        [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
                        [-o:a OPTIONS_ALL] [-s SETTINGS] [-s:b SETTINGS_BUILD]
                        [-s:h SETTINGS_HOST] [-s:a SETTINGS_ALL] [-c CONF]
                        [-c:b CONF_BUILD] [-c:h CONF_HOST] [-c:a CONF_ALL]
                        [path]

Create a package directly from pre-compiled binaries.

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

options:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        Select the output format: json
  --out-file OUT_FILE   Write the output of the command to the specified file
                        instead of stdout.
  -v [{quiet,error,warning,notice,status,,verbose,debug,v,trace,vv}]
                        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
  -of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER
                        The root output folder for generated and build files
  --build-require       Whether the provided reference is a build-require
  -tf TEST_FOLDER, --test-folder TEST_FOLDER
                        Alternative test folder name. By default it is
                        "test_package". Use "" to skip the test stage
  -sb, --skip-binaries  Skip installing dependencies binaries
  -r REMOTE, --remote REMOTE
                        Look in the specified remote or remotes server
  -nr, --no-remote      Do not use remote, resolve exclusively in the cache

reference arguments:
  --name NAME           Provide a package name if not specified in conanfile
  --version VERSION     Provide a package version if not specified in
                        conanfile
  --user USER           Provide a user if not specified in conanfile
  --channel CHANNEL     Provide a channel if not specified in conanfile

lockfile arguments:
  -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
  --lockfile-out LOCKFILE_OUT
                        Filename of the updated lockfile
  --lockfile-clean      Remove unused entries from the lockfile
  --lockfile-overrides LOCKFILE_OVERRIDES
                        Overwrite lockfile overrides

profile arguments:
  -pr PROFILE, --profile PROFILE
                        Apply the specified profile. By default, or if
                        specifying -pr:h (--profile:host), it applies to the
                        host context. Use -pr:b (--profile:build) to specify
                        the build context, or -pr:a (--profile:all) to specify
                        both contexts at once
  -pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
  -pr:h PROFILE_HOST, --profile:host PROFILE_HOST
  -pr:a PROFILE_ALL, --profile:all PROFILE_ALL
  -o OPTIONS, --options OPTIONS
                        Apply the specified options. By default, or if
                        specifying -o:h (--options:host), it applies to the
                        host context. Use -o:b (--options:build) to specify
                        the build context, or -o:a (--options:all) to specify
                        both contexts at once. Example:
                        -o="pkg/*:with_qt=True"
  -o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
  -o:h OPTIONS_HOST, --options:host OPTIONS_HOST
  -o:a OPTIONS_ALL, --options:all OPTIONS_ALL
  -s SETTINGS, --settings SETTINGS
                        Apply the specified settings. By default, or if
                        specifying -s:h (--settings:host), it applies to the
                        host context. Use -s:b (--settings:build) to specify
                        the build context, or -s:a (--settings:all) to specify
                        both contexts at once. Example: -s="compiler=gcc"
  -s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
  -s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
  -s:a SETTINGS_ALL, --settings:all SETTINGS_ALL
  -c CONF, --conf CONF  Apply the specified conf. By default, or if specifying
                        -c:h (--conf:host), it applies to the host context.
                        Use -c:b (--conf:build) to specify the build context,
                        or -c:a (--conf:all) to specify both contexts at once.
                        Example:
                        -c="tools.cmake.cmaketoolchain:generator=Xcode"
  -c:b CONF_BUILD, --conf:build CONF_BUILD
  -c:h CONF_HOST, --conf:host CONF_HOST
  -c:a CONF_ALL, --conf:all CONF_ALL

conan export-pkg 命令直接从用户文件夹中的预编译二进制文件创建软件包二进制文件。此命令在不同情况下可能很有用:

  • 为供应商提供的某些闭源或预编译二进制文件创建软件包时。在这种情况下,conanfile.py 配方不必包含 build() 方法,而提供 package()package_info() 方法足以打包这些预编译二进制文件。在这种情况下,build_policy = "never" 可能很有意义,表示无法 conan install --build=this_pkg,因为它不知道如何从源代码构建,而它又是一个依赖项。

  • 本地开发流程中本地测试某个配方时,可以使用它将本地构建的二进制文件快速放入缓存,以便其他软件包进行测试,而无需经过完整的 conan create,后者会比较慢。

一般来说,预计当 conan export-pkg 执行时,构建该软件包所需的 Conan 依赖项已经通过 conan install 安装完毕,因此在 export-pkg 时无需下载依赖项。但如果出于某种原因不是这种情况,该命令定义了 --remote--no-remote 参数,与其他命令类似,以及 --skip-binaries 优化,这可以节省一些安装依赖项二进制文件的时间,如果它们不是当前 export-pkg 所必需的话。但这由用户负责,因为这些二进制文件实际上可能是必需的,例如,如果使用了 tool_requires = "cmake/x.y" 并且 package() 方法实现了 cmake.install() 调用,那么这绝对需要当前机器上安装的依赖项的二进制文件才能执行。

conan export-pkg 是一个软件包创建命令,它将创建一个新的配方和一个新的软件包二进制文件,就像 conan create 命令一样。同样,它会在软件包创建后运行任何“test-package”功能。如果除了 conanfile.py 之外还有一个 test_package 文件夹,或者通过 --test-folder/-tf 参数或配方 test_package_folder 属性定义了不同的 test-package 文件夹,那么将触发该 test-package 来测试和验证创建的软件包是否可被 test-package 文件夹中的简单消费者项目使用。

另请参阅