conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.22k stars 980 forks source link

[feature] provides keyword (or alternative) to be considered in version resolving process #9166

Closed KerstinKeller closed 3 years ago

KerstinKeller commented 3 years ago

Conan 1.28 has introduced the provides keyword, and the user gets an error if multiple recipes provide the same functionality. I know it's still marked as experimental, but I would like to remark that it would be very beneficial if the provides keyword (or a separate one) could suggest that conan uses that information in the version resolving process.

Lets take the libjpeg and libjpeg-turbo example. libjpeg-turbo provides libjpeg. Consumer recipes can use options to toggle between both dependencies https://github.com/conan-io/conan-center-index/blob/41d4fbb8c218f9d938ccb8b9d888bff52002e62e/recipes/libyuv/all/conanfile.py#L40-L44 However using just libjpeg, or for example with a special syntax like proposed for alias versions (libjpeg) could lead to cleaner recipes.

While I can image that the version resolving might get arbitrary complicated when also considering provides, it leads to less cluttered recipes. Wondering how you feel about it!

memsharded commented 3 years ago

Hi @KerstinKeller

We have thought about using the provides as a "name", and use it in the dependency resolution, but we have realized that it makes the problem way more complex, as it introduces a new dimension in something that is very core, and is used in many places in the Conan. The package name is used in dictionaries keys as a unique, hashable thing. The "alternative" names that provides bring is not hashable, and even worse, it is not even fixed size (one recipe can provide multiple different things, many different packages can provide the same thing, not necessarily matching an existing package name, it can be a common name), and it is not possible to get it after actually fetching and evaluating the recipe. We haven't found any reasonable way to manage it.

So at the moment we only consider the provides as "fail fast" mechanism to identify quickly this case (instead of weird link errors later), but resolving the situation can only be managed manually (like with options).