Conan

Conan -- 开源 C/C++ 程序包管理器。「Conan - The open-source C/C++ package manager」

Github stars Tracking Chart

Conan(柯南)

去中心化和开源(MIT)的 C/C++ 包管理器。

Conan 是面向 C 和 C++ 开发人员的软件包管理器:

  • 它是完全分散的。用户可以将其软件包托管在自己的服务器中。与 Artifactory 和 Bintray 集成。
  • 便携。可以跨所有平台工作,包括 Linux、OSX、Windows(具有本机和一流的支持,WSL、MinGW)、Solaris、FreeBSD,嵌入式和交叉编译,docker,WSL
  • 二进制文件管理。它可以为任何配置和平台创建、上传和下载二进制文件,甚至可以进行交叉编译,从而节省了大量开发和持续集成时间。二进制兼容性可以配置和定制。在所有平台上以相同方式管理所有工件。
  • 与任何构建系统集成,包括任何专有和定制的构建系统。为主要构建系统(CMake,MSBuild,Makefiles,Meson 等)提供经过测试的支持。
  • 可扩展:其基于 python 的配方以及扩展点可实现强大的功能和灵活性。
  • 活跃的大型社区,尤其是在 Github(https://github.com/conan-io/conan)和 Slack(https://cpplang-inviter.cppalliance.org/)中。该社区还在 Bintray 的 ConanCenter 和 Bincrafters 信息库中创建和维护软件包。
  • 稳定。许多公司都在生产中使用该产品。从1.0开始,大家承诺不会破坏包的配方和文档化的行为。

建立

请阅读 https://docs.conan.io/en/latest/installation.html 以了解如何安装和开始使用柯南。TL;DR:

$ pip install conan

安装开发版本

您可以在 Windows、MacOS 和 Linux 中运行柯南客户端和服务器。

  • 根据 pip 文档 安装pip。
  • 克隆 Conan 存储库:
    $ git clone https://github.com/conan-io/conan.git
            
  • 以可编辑模式安装
    $ cd conan && sudo pip install -e .
            
    如果您在 Windows 中,则不需要使用 sudo
  • 现在你已准备好了, 试试运行 Conan:
    $ conan --help
    Consumer commands
      install    Installs the requirements specified in a conanfile (.py or .txt).
      config     Manages configuration. Edits the conan.conf or installs config files.
      get        Gets a file or list a directory of a given reference or package.
      info       Gets information about the dependency graph of a recipe.
      search     Searches package recipes and binaries in the local cache or in a remote.
    Creator commands
      new        Creates a new package recipe template with a 'conanfile.py'.
      create     Builds a binary package for a recipe (conanfile.py) located in the current dir.
      upload     Uploads a recipe and binary packages to a remote.
      export     Copies the recipe (conanfile.py & associated files) to your local cache.
      export-pkg Exports a recipe & creates a package with given files calling 'package'.
      test       Test a package, consuming it with a conanfile recipe with a test() method.
    Package development commands
      source     Calls your local conanfile.py 'source()' method.
      build      Calls your local conanfile.py 'build()' method.
      package    Calls your local conanfile.py 'package()' method.
    Misc commands
      profile    Lists profiles in the '.conan/profiles' folder, or shows profile details.
      remote     Manages the remote list and the package recipes associated with a remote.
      user       Authenticates against a remote with user/pass, caching the auth token.
      imports    Calls your local conanfile.py or conanfile.txt 'imports' method.
      copy       Copies conan recipes and packages to another user/channel.
      remove     Removes packages or binaries matching pattern from local cache or remote.
      alias      Creates and exports an 'alias recipe'.
      download   Downloads recipe and binaries to the local cache, without using settings.
    Conan commands. Type "conan <command> -h" for help
        

为项目做贡献

在这个项目中,反馈和贡献总是受欢迎的。请阅读我们的。请阅读我们的贡献指南

运行测试

使用 tox

$ python -m tox

它将安装所需的依赖项,并跳过一些繁琐而缓慢的测试。 如果要运行完整的测试套件,请执行以下操作:

没有 tox

安装 python 依赖

$ python -m pip install -r conans/requirements.txt
$ python -m pip install -r conans/requirements_server.txt
$ python -m pip install -r conans/requirements_dev.txt

如果不是 Windows,并且没有使用 python 虚拟环境,则需要使用 sudo 运行这些命令。

在运行测试之前,您需要首先设置一些环境变量。

$ export PYTHONPATH=$PYTHONPATH:$(pwd)

在 Windows 上,它将是(位于 Conan 根目录中):

$ set PYTHONPATH=.

确保您的 cmake 具有 2.8 或更高版本。您可以使用以下命令查看版本:

$ cmake --version

CONAN_COMPILER 和 CONAN_COMPILER_VERSION 的适当值取决于您的操作系统和要求。

这些应该在 Ubuntu 14.04 上的 build-essential 中对 GCC 起作用:

$ export CONAN_COMPILER=gcc
$ export CONAN_COMPILER_VERSION=4.8

这些应该适用于 OS X:

$ export CONAN_COMPILER=clang
$ export CONAN_COMPILER_VERSION=3.5

您可以像这样运行实际的测试:

$ python -m nose .

这里定义了两个测试属性,您可以使用它们来过滤测试,并且不执行它们:

$ python -m nose . -a !slow

几分钟后,它应该显示 OK:

............................................................................................
----------------------------------------------------------------------
Ran 146 tests in 50.993s
OK

要运行特定的测试,您还可以指定测试名称,类似于:

$ python -m nose conans.test.command.config_install_test:ConfigInstallTest.install_file_test --nocapture

nocapture 参数可以用于查看一些由 nosetests 捕获的输出。

许可

MIT LICENSE

(The first version translated by vz on 2020.07.01)


Main metrics

Overview
Name With Ownerconan-io/conan
Primary LanguagePython
Program languagePython (Language Count: 2)
PlatformBSD, Linux, Mac, Solaris, Windows, Raspbian
License:MIT License
所有者活动
Created At2015-12-01 13:17:02
Pushed At2025-06-10 16:08:45
Last Commit At
Release Count343
Last Release Name2.17.0 (Posted on 2025-05-28 17:34:35)
First Release Name0.4.0 (Posted on )
用户参与
Stargazers Count8.8k
Watchers Count129
Fork Count1k
Commits Count9.2k
Has Issues Enabled
Issues Count11402
Issue Open Count816
Pull Requests Count5685
Pull Requests Open Count60
Pull Requests Close Count867
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

|Logo|

Conan

Decentralized, open-source (MIT), C/C++ package manager.

Conan is a package manager for C and C++ developers:

  • It is fully decentralized. Users can host their packages in their servers, privately. Integrates with Artifactory and Bintray.
  • Portable. Works across all platforms, including Linux, OSX, Windows (with native and first-class support, WSL, MinGW),
    Solaris, FreeBSD, embedded and cross-compiling, docker, WSL
  • Manage binaries. It can create, upload and download binaries for any configuration and platform,
    even cross-compiling, saving lots of time in development and continuous integration. The binary compatibility
    can be configured and customized. Manage all your artifacts in the same way on all platforms.
  • Integrates with any build system, including any proprietary and custom one. Provides tested support for major build systems
    (CMake, MSBuild, Makefiles, Meson, etc).
  • Extensible: Its python based recipes, together with extensions points allows for great power and flexibility.
  • Large and active community, especially in Github (https://github.com/conan-io/conan) and Slack (https://cpplang.now.sh/ #conan channel).
    This community also creates and maintains packages in Conan-center and Bincrafters repositories in Bintray.
  • Stable. Used in production by many companies, since 1.0 there is a commitment not to break package recipes and documented behavior.

+------------------------+-------------------------+-------------------------+-------------------------+
| master | develop | Coverage | Code Climate |
+========================+=========================+=========================+=========================+
| |Build Status Master| | |Build Status Develop| | |Develop coverage| | |Develop climate| |
+------------------------+-------------------------+-------------------------+-------------------------+

Setup

Please read https://docs.conan.io/en/latest/installation.html

From binaries

We have installers for most platforms here <http://conan.io>__ but you
can run conan from sources if you want.

From pip

Conan is compatible with Python 2 and Python 3.

  • Install pip following pip docs_.

  • Install conan:

    .. code-block:: bash

      $ pip install conan
    

You can also use test.pypi.org <https://test.pypi.org/project/conan/#history>_ repository to install development (non-stable) Conan versions:

.. code-block:: bash

    $ pip install --index-url https://test.pypi.org/simple/ conan

From Homebrew (OSx)

  • Install Homebrew following brew homepage_.

    .. code-block:: bash

    $ brew update
    $ brew install conan
    

From source

You can run conan client and server in Windows, MacOS, and Linux.

  • Install pip following pip docs_.

  • Clone conan repository:

    .. code-block:: bash

    $ git clone https://github.com/conan-io/conan.git
    
  • Install in editable mode

    .. code-block:: bash

      $ cd conan && sudo pip install -e .
    

    If you are in Windows, using sudo is not required.

  • You are ready, try to run conan:

    .. code-block::

    $ conan --help

    Consumer commands
    install Installs the requirements specified in a conanfile (.py or .txt).
    config Manages configuration. Edits the conan.conf or installs config files.
    get Gets a file or list a directory of a given reference or package.
    info Gets information about the dependency graph of a recipe.
    search Searches package recipes and binaries in the local cache or in a remote.
    Creator commands
    new Creates a new package recipe template with a 'conanfile.py'.
    create Builds a binary package for a recipe (conanfile.py) located in the current dir.
    upload Uploads a recipe and binary packages to a remote.
    export Copies the recipe (conanfile.py & associated files) to your local cache.
    export-pkg Exports a recipe & creates a package with given files calling 'package'.
    test Test a package, consuming it with a conanfile recipe with a test() method.
    Package development commands
    source Calls your local conanfile.py 'source()' method.
    build Calls your local conanfile.py 'build()' method.
    package Calls your local conanfile.py 'package()' method.
    Misc commands
    profile Lists profiles in the '.conan/profiles' folder, or shows profile details.
    remote Manages the remote list and the package recipes associated with a remote.
    user Authenticates against a remote with user/pass, caching the auth token.
    imports Calls your local conanfile.py or conanfile.txt 'imports' method.
    copy Copies conan recipes and packages to another user/channel.
    remove Removes packages or binaries matching pattern from local cache or remote.
    alias Creates and exports an 'alias recipe'.
    download Downloads recipe and binaries to the local cache, without using settings.

    Conan commands. Type "conan -h" for help

Contributing to the project

Feedback and contribution are always welcome in this project.
Please read our contributing guide <https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md>_.

Running the tests

Using tox

.. code-block:: bash

$ tox

It will install the needed requirements and launch nose skipping some heavy and slow tests.
If you want to run the full test suite:

.. code-block:: bash

$ tox -e full

Without tox

Install python requirements

.. code-block:: bash

$ pip install -r conans/requirements.txt
$ pip install -r conans/requirements_server.txt
$ pip install -r conans/requirements_dev.txt

Only in OSX:

.. code-block:: bash

$ pip install -r conans/requirements_osx.txt # You can omit this one if not running OSX

If you are not Windows and you are not using a python virtual environment, you will need to run these
commands using sudo.

Before you can run the tests, you need to set a few environment variables first.

.. code-block:: bash

$ export PYTHONPATH=$PYTHONPATH:$(pwd)

On Windows it would be (while being in the conan root directory):

.. code-block:: bash

$ set PYTHONPATH=.

Ensure that your cmake has version 2.8 or later. You can see the
version with the following command:

.. code-block:: bash

$ cmake --version

The appropriate values of CONAN_COMPILER and CONAN_COMPILER_VERSION depend on your
operating system and your requirements.

These should work for the GCC from build-essential on Ubuntu 14.04:

.. code-block:: bash

$ export CONAN_COMPILER=gcc
$ export CONAN_COMPILER_VERSION=4.8

These should work for OS X:

.. code-block:: bash

$ export CONAN_COMPILER=clang
$ export CONAN_COMPILER_VERSION=3.5

You can run the actual tests like this:

.. code-block:: bash

$ nosetests .

There are a couple of test attributes defined, as slow that you can use
to filter the tests, and do not execute them:

.. code-block:: bash

$ nosetests . -a !slow

A few minutes later it should print OK:

.. code-block:: bash

............................................................................................
----------------------------------------------------------------------
Ran 146 tests in 50.993s

OK

To run specific tests, you can specify the test name too, something like:

.. code-block:: bash

$ nosetests conans.test.command.config_install_test:ConfigInstallTest.install_file_test --nocapture

The --nocapture argument can be useful to see some output that otherwise is captured by nosetests.

License

MIT LICENSE <./LICENSE.md>__

.. |Build Status Master| image:: https://conan-ci.jfrog.info/buildStatus/icon?job=ConanTestSuite/master
:target: https://conan-ci.jfrog.info/job/ConanTestSuite/job/master

.. |Build Status Develop| image:: https://conan-ci.jfrog.info/buildStatus/icon?job=ConanTestSuite/develop
:target: https://conan-ci.jfrog.info/job/ConanTestSuite/job/develop

.. |Master coverage| image:: https://codecov.io/gh/conan-io/conan/branch/master/graph/badge.svg
:target: https://codecov.io/gh/conan-io/conan/branch/master

.. |Develop coverage| image:: https://codecov.io/gh/conan-io/conan/branch/develop/graph/badge.svg
:target: https://codecov.io/gh/conan-io/conan/branch/develop

.. |Coverage graph| image:: https://codecov.io/gh/conan-io/conan/branch/develop/graphs/tree.svg
:height: 50px
:width: 50 px
:alt: Conan develop coverage

.. |Develop climate| image:: https://api.codeclimate.com/v1/badges/081b53e570d5220b34e4/maintainability.svg
:target: https://codeclimate.com/github/conan-io/conan/maintainability

.. |Logo| image:: https://conan.io/img/jfrog_conan_logo.png

.. _pip docs: https://pip.pypa.io/en/stable/installing/

.. _brew homepage: http://brew.sh/