有没有办法将python依赖项添加到conan包

Ale*_*per 5 python package-management conan

我正在使用 C/C++ 和 Python 中的多个库和包建立一个项目。

I would like to setup a binary repository for C/C++ packages and a python package index server for python packages.

I stumbled upon conan and artefactory to handle inter C/C++ libraries dependencies but I can't find a clear solution to add standard python package dependencies.

For instance, my project 'A' (C/C++) depends on 'B' (C/C++) that contains code generated using 'C' tool (Python).

I would like to set a requirement for 'B' to 'C' as a pip requirement for a specific distribution of my 'C' tool package.

So far, the solutions I see are:

  1. Create a conan package for my 'C'' tool and add requirement in 'B'
  2. Handle manually the 'C' package install in 'B' conanfile.py

I would like to avoid to add a conan package for a python package since python has already a package management system and my packages will be available on a python index server.

I would also avoid to add code to handle python package dependencies.

Does anyone have an idea if this is possible with conan in a simple matter ?

Thank you

Alex

uil*_*ies 6

由于 Conan 配方也是 Python 脚本,因此您可以直接从配方运行 pip:

 def system_requirements(self):
    import pip
    if hasattr(pip, "main"):
        pip.main(["install", "colorama"])
    else:
        from pip._internal import main
        main(['install', "colorama"])
Run Code Online (Sandbox Code Playgroud)

系统要求是最好的地方,因为与所需的包相关,但不是柯南包。如果您有一些基于发行版的条件需要添加,您也可以使用 distro_info。

请查看文档中的此处,以获取更多信息。

问候!