conan-io / conan

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

[question] How do I specify a particular package ID in the requirements section in my conanfile.(txt/py)? #17291

Open DillonNMorse opened 2 weeks ago

DillonNMorse commented 2 weeks ago

What is your question?

I am trying to build a project which requires opentelemetry-cpp, in particular I need a build with: with_otlp_grpc: True. From your opentelemetry-cpp recipes page I can see that what I want is package ID = fa03e336ba0faf7b6f1dd9079c5a49d19db04962 How can I specify this particular package ID in my conanfile (either txt or py)?

For example, in my conanfile.txt I have tried: opentelemetry-cpp/1.14.2#6bafec80cf465b03b6e8521e9dcf395b:fa03e336ba0faf7b6f1dd9079c5a49d19db04962 hoping that the syntax was <package name>/<package version>#<Recipe Revision>:<package ID> but I receive the following error message when executing conan install ...:

ERROR: Package 'opentelemetry-cpp/1.14.2' not resolved: Unable to find 'opentelemetry-cpp/1.14.2#6bafec80cf465b03b6e8521e9dcf395b:fa03e336ba0faf7b6f1dd9079c5a49d19db04962' in remotes.

Among our team we are finding that anyone that has tried to re-install the conan libraries within the last week is running into an issue wherein we fail to find the appropriate otlp grpc libraries - presumably because we are now inadvertently pulling a package with with_otlp_grpc: False. Is it necessary to pin not only the package versions but also the package ID's in the requirements section of our conafile?

Have you read the CONTRIBUTING guide?

memsharded commented 2 weeks ago

Hi @DillonNMorse

Thanks for your question

How can I specify this particular package ID in my conanfile (either txt or py)?

It is not possible to specify the package_id from the consumers. The package_id is always computed as a function of multiple parameters, including profile settings, options, and also dependencies versions, see: https://docs.conan.io/2/reference/binary_model.html. Note from https://docs.conan.io/2/reference/binary_model/dependencies.html section, that dependencies can affect the package_id of the consumer, also if some of the dependencies options changes, for "embed" cases.

Among our team we are finding that anyone that has tried to re-install the conan libraries within the last week is running into an issue wherein we fail to find the appropriate otlp grpc libraries - presumably because we are now inadvertently pulling a package with with_otlp_grpc: False. Is it necessary to pin not only the package versions but also the package ID's in the requirements section of our conafile?

Yes, this might happen if some recipe has changed recently in ConanCenter, and changed any of their options or something like that. It is not frequent, but sometimes might happen.

It is not possible to pin package_id. The recommended ways to manage the continuously evolving ConanCenter recipes are:

Please see https://docs.conan.io/2/devops/using_conancenter.html for more details.

Let us know if this clarifies things, thanks for your feedback.

memsharded commented 5 days ago

Any further question or feedback?