conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] Overriding requirements for packaging pre-built binaries

Open Nekto89 opened this issue 3 years ago • 3 comments

I want to package library that was built with specific set of options/requirements. I'm trying to use conan export-pkg for this. I can pass options easily through profile. But I don't see API for overriding requirements in export-pkg. So I'm getting error if I specify transitive dependencies in recipe: ConanException: mylibrary/1.0.0.0@user/channel package_info(): Package require 'bzip2' not used in components requires. If I don't specify dependencies - wrong version of dependency is being used. Is there a way to somehow inject these dependencies? The only current workaround that I can think of is creating some fake component that will depend on transitive requirements just so that I don't get this error.

Nekto89 avatar Sep 13 '22 11:09 Nekto89

I want to package library that was built with specific set of options/requirements. I'm trying to use conan export-pkg for this

It is not fully clear how you built this in the first place, and why a conan create flow doesn't fit your use case. Because export-pkg use case is to package pre-compiled binaries, (not from Conan), but in this case it seems that you are actually building with Conan, because you have requirements that you are trying to override. If you can elaborate a bit more, that would be useful to understand your use case.

memsharded avatar Sep 13 '22 13:09 memsharded

I want to package library that was built with specific set of options/requirements. I'm trying to use conan export-pkg for this

It is not fully clear how you built this in the first place, and why a conan create flow doesn't fit your use case. Because export-pkg use case is to package pre-compiled binaries, (not from Conan), but in this case it seems that you are actually building with Conan, because you have requirements that you are trying to override. If you can elaborate a bit more, that would be useful to understand your use case.

I have complex CMake project with lots of components that can be enabled/disabled that I've transformed into using "cmake internally for getting dependencies. I'm mostly using recipes from CCI that are copied to Artifactory server with custom user/channel to have better control over changes and reproducible builds. All overrides are given to conan install step which works perfectly. In the end of build process I have multiple static libraries that I want to pack into conan package. I want users to be able to get them only if they have matching conan options (full_package_mode).

It's not clear how to deal with transitive dependencies like bzip2. My library doesn't depend on bzip2 directly but it depends on Boost that brings bzip2 if boost:bzip2==True. So I still need to use specific version of bzip2 that was used for building library.

Nekto89 avatar Sep 13 '22 13:09 Nekto89

For now I've decided to go with fake component for silencing errors. self.cpp_info.components["DummyComponent"].requires = ["bzip2::bzip2", "pcre::libpcre", "xz_utils::xz_utils", "zstd::zstdlib"]

My current workflow looks like this:

  • compile binaries
  • convert conaninfo.txt that was generated by conan-cmake into profile by copying [full_settings] into [settings] and [full_options] into [options]
  • hardcode all required dependencies with user/channel that I need into recipe
  • conan export-pkg -bf . -f -pr:h pathtoprofile pathtoconanfile.py library/version@user/channel
  • conan test -pr:h pathtoprofile pathtotest_package/conanfile.py library/version@user/channel

Nekto89 avatar Sep 14 '22 07:09 Nekto89