# 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 cpt.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 cpt.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 cpt.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 cpt.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 arch=x86/
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | conan_package_tools-0.19.8.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 81 浏览量
2022-01-10
03:21:26
上传
评论
收藏 44KB GZ 举报
温馨提示
共41个文件
py:30个
txt:7个
pkg-info:2个
资源来自pypi官网。 资源全名:conan_package_tools-0.19.8.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
conan_package_tools-0.19.8.tar.gz (41个子文件)
conan_package_tools-0.19.8
setup.py 4KB
conan_package_tools.egg-info
top_level.txt 10B
SOURCES.txt 998B
PKG-INFO 767B
entry_points.txt 64B
dependency_links.txt 1B
requires.txt 77B
setup.cfg 38B
cpt
requirements.txt 77B
builds_generator.py 17KB
__init__.py 24B
run_in_docker.py 2KB
log.py 1KB
printer.py 4KB
packager.py 24KB
profiles.py 3KB
requirements_test.txt 89B
tools.py 745B
uploader.py 2KB
runner.py 11KB
ci_manager.py 5KB
test
__init__.py 0B
integration
__init__.py 0B
basic_test.py 6KB
base.py 2KB
upload_test.py 6KB
remotes_test.py 1KB
docker_test.py 5KB
unit
ci_manager_test.py 7KB
__init__.py 0B
packager_test.py 38KB
utils.py 3KB
generators_test.py 56KB
auth_test.py 7KB
remotes_test.py 1KB
remotes.py 6KB
auth.py 5KB
README.md 44KB
PKG-INFO 767B
conan
__init__.py 0B
packager.py 198B
共 41 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 12w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功