Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to add python dependencies to conan package

I am setting up a project using multiple libraries and packages in C/C++ and 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

like image 293
Alexper Avatar asked Feb 02 '19 13:02

Alexper


People also ask

How do I get python package dependencies?

Download Dependencies OnlyUse the pipdeptree utility to gather a list of all dependencies, create a requirements. txt file listing all the dependencies, and then download them with the pip download command. Get the list of dependencies for a package from the setup.py file.

How do I get dependencies for pip package?

Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.

How do I add packages to conan?

The specific steps to add new packages are: Fork the conan-center-index git repository, and then clone it locally. Copy a template from package_templates folder in the recipes/ folder and rename it to the project name (it should be lower-case). Read templates documentation to find more information.


1 Answers

Since a Conan recipe is also a Python script, you could run pip directly from the recipe:

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

System requirements is the best place, because is related to a required package that is not a Conan package. If you have some condition to be added based on distro, you can use distro_info too.

Take a look here in the documentation, to get more information about.

Regards!

like image 128
uilianries Avatar answered Oct 04 '22 02:10

uilianries