Conan: Support multiple versions on requires

Created on 13 Mar 2018  路  3Comments  路  Source: conan-io/conan

Hi!

Running Conan 1.1.1 I would like to use the same package twice, but using totally different versions:

class Foobar(ConanFile):
    name = "foobar"
    version = "0.1.0"
    settings = "os", "compiler", "build_type", "arch"
    requires = "bar/1.0.0@user/stable", "bar/0.1.0@user/stable"

    ...

ERROR: conanfile.py: Error while initializing requirements. Duplicated requirement bar/1.0.0@user/stable != bar/0.1.0@user/stable

Why I need such behavior?
Well, some few projects (libusb), when the major version was updated, the project was complete reformulated. Even headers, libraries and all others files have different names, as a new project.

In my case, I have a project using both versions -- Okay, I should update the project. However, I'm able to link when I solve my dependencies by distro package manager.

Could be possible to add a flag to run both versions together. WDYT?

To help us debug your issue please explain:

  • [X] I've read the CONTRIBUTING guide.
  • [X] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [X] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Most helpful comment

Yes, I'd recommend to package "libusb0", and "libusb", for example, 200%.
So then in your consumer code, you explicitly link e.g. with CONAN_PKG::libusb0 target, when you want to.

All 3 comments

It is almost impossible.
All the conan dependency graph computation is mostly based by the package name. The version and the rest of information is overriden.

Even if the graph could be computed for your example, and both "bar" package versions are in the graph, it could be a total mess of include directories, library directories, library names... etc. To which targets/libraries you will link? The fact that you managed to do a build for a certain library against 2 versions, cannot be generalized for a package manager.

In order to be able to do such a thing, it is expected that the name of the package would be different, like Catch/Catch2, otherwise it is a guaranteed path to hell :) :)

I see. So would prefer to split the original package, as you commented.

In my case, I'm using libusb 1.0.21 and libusb 0.1.12. The same project here uses both two versions :man_facepalming:

Thanks for you quick answer, regards!

Yes, I'd recommend to package "libusb0", and "libusb", for example, 200%.
So then in your consumer code, you explicitly link e.g. with CONAN_PKG::libusb0 target, when you want to.

Was this page helpful?
0 / 5 - 0 ratings