# Conan Package Tools [![Build Status](https://travis-ci.org/conan-io/conan-package-tools.svg?branch=master)](https://travis-ci.org/conan-io/conan-package-tools)
## Introduction
This package allows to automate the creation of [conan](https://github.com/conan-io/conan) packages for different configurations.
It eases the integration with CI servers like [TravisCI](https://travis-ci.org/) and [Appveyor](http://www.appveyor.com/), so you can use the
cloud to generate different binary packages for your conan recipe.
Also supports Docker to create packages for different **GCC and Clang** versions.
## Installation
$ pip install conan_package_tools
Or you can [clone this repository](http://github.com/conan-io/conan-package-tools) and store its location in PYTHONPATH.
## How it works
Using only conan C/C++ package manager (without conan package tools), you can use the `conan create` command to generate, for the same recipe, different binary packages for different configurations.
The easier way to do it is using profiles:
$ conan create myuser/channel --profile win32
$ conan create myuser/channel --profile raspi
$ ...
The profiles can contain, settings, options, environment variables and build_requires. Take a look to the [conan docs](https://docs.conan.io) to know more.
`Conan package tools` allows to declare (or autogenerate) a set of different configurations (different profiles). It will call `conan create` for each one, uploading the generated packages
to a remote (if needed), and using optionally docker images to ease the creation of different binaries for different compiler versions (gcc and clang supported).
### Basic, but not very practical, example
Create a **build.py** file in your recipe repository, and add the following lines:
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager(username="myusername")
builder.add(settings={"arch": "x86", "build_type": "Debug"},
options={}, env_vars={}, build_requires={})
builder.add(settings={"arch": "x86_64", "build_type": "Debug"},
options={}, env_vars={}, build_requires={})
builder.run()
Now we can run the python script, the `ConanMutiPackager` will run the `conan create` command two times, one to generate `x86 Debug` package and
another one for `x86_64 Debug`.
> python build.py
############## CONAN PACKAGE TOOLS ######################
INFO: ******** RUNNING BUILD **********
conan create myuser/testing --profile /var/folders/y1/9qybgph50sjg_3sm2_ztlm6dr56zsd/T/tmpz83xXmconan_package_tools_profiles/profile
[build_requires]
[settings]
arch=x86
build_type=Debug
[options]
[scopes]
[env]
...
############## CONAN PACKAGE TOOLS ######################
INFO: ******** RUNNING BUILD **********
conan create myuser/testing --profile /var/folders/y1/9qybgph50sjg_3sm2_ztlm6dr56zsd/T/tmpMiqSZUconan_package_tools_profiles/profile
[build_requires]
[settings]
arch=x86_64
build_type=Debug
[options]
[scopes]
[env]
#########################################################
...
If we inspect the local cache we can see that there are two binaries generated for our recipe, in this case the zlib recipe:
$ conan search zlib/1.2.11@myuser/testing
Existing packages for recipe zlib/1.2.11@myuser/testing:
Package_ID: a792eaa8ec188d30441564f5ba593ed5b0136807
[options]
shared: False
[settings]
arch: x86
build_type: Debug
compiler: apple-clang
compiler.version: 9.0
os: Macos
outdated from recipe: False
Package_ID: e68b263f26a4d7513e28c9cae1673aa0466af777
[options]
shared: False
[settings]
arch: x86_64
build_type: Debug
compiler: apple-clang
compiler.version: 9.0
os: Macos
outdated from recipe: False
Now, we could add new build configurations, but in this case we only want to add Visual Studio configurations and the runtime, but, of course, only if we are on Windows:
import platform
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager(username="myusername")
if platform.system() == "Windows":
builder.add(settings={"arch": "x86", "build_type": "Debug", "compiler": "Visual Studio", "compiler.version": 14, "compiler.runtime": "MTd"},
options={}, env_vars={}, build_requires={})
builder.add(settings={"arch": "x86_64", "build_type": "Release", "compiler": "Visual Studio", "compiler.version": 14, "compiler.runtime": "MT"},
options={}, env_vars={}, build_requires={})
else:
builder.add(settings={"arch": "x86", "build_type": "Debug"},
options={}, env_vars={}, build_requires={})
builder.add(settings={"arch": "x86_64", "build_type": "Debug"},
options={}, env_vars={}, build_requires={})
builder.run()
In the previous example, when we are on Windows, we are adding two build configurations:
- "Visual Studio 14, Debug, MTd runtime"
- "Visual Studio 14, Release, MT runtime"
We can also adjust the options, environment variables and build_requires:
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager(username="myuser")
builder.add({"arch": "x86", "build_type": "Release"},
{"mypackage:option1": "ON"},
{"PATH": "/path/to/custom"},
{"*": ["MyBuildPackage/1.0@lasote/testing"]})
builder.add({"arch": "x86_64", "build_type": "Release"}, {"mypackage:option1": "ON"})
builder.add({"arch": "x86", "build_type": "Debug"}, {"mypackage:option2": "OFF", "mypackage:shared": True})
builder.run()
We could continue adding configurations, but probably you realized that it would be such a tedious task if you want to generate many different configurations
in different operating systems, using different compilers, different compiler versions etc.
## Generating the build configurations automatically
Conan package tools can generate automatically a matrix of build configurations combining architecture, compiler, compiler.version, compiler.runtime, compiler.libcxx, build_type and
and shared/static options.
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager()
builder.add_common_builds()
builder.run()
If you run the ``python build.py`` command, for instance, in Mac OSX, it will add the following configurations automatically:
```
{'compiler.version': '7.3', 'arch': 'x86', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '7.3', 'arch': 'x86', 'build_type': 'Debug', 'compiler': 'apple-clang'})
{'compiler.version': '7.3', 'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '7.3', 'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang'})
{'compiler.version': '8.0', 'arch': 'x86', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '8.0', 'arch': 'x86', 'build_type': 'Debug', 'compiler': 'apple-clang'})
{'compiler.version': '8.0', 'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '8.0', 'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang'})
{'compiler.version': '8.1', 'arch': 'x86', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '8.1', 'arch': 'x86', 'build_type': 'Debug', 'compiler': 'apple-clang'})
{'compiler.version': '8.1', 'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang'})
{'compiler.version': '8.1', 'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang'})
```
These are all the combinations of a
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共22个文件
py:11个
txt:7个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:conan_package_tools-0.7.5.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
conan_package_tools-0.7.5.tar.gz (22个子文件)
conan_package_tools-0.7.5
PKG-INFO 766B
setup.cfg 38B
setup.py 4KB
README.md 36KB
conan
tools.py 135B
test
generators_test.py 30KB
packager_test.py 22KB
__init__.py 0B
requirements_test.txt 11B
__init__.py 23B
packager.py 23KB
run_in_docker.py 351B
requirements.txt 45B
log.py 1KB
builds_generator.py 9KB
create_runner.py 8KB
conan_package_tools.egg-info
PKG-INFO 766B
requires.txt 45B
SOURCES.txt 546B
entry_points.txt 66B
top_level.txt 6B
dependency_links.txt 1B
共 22 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功