conan-io / conan

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

On using requires() - Installing my own created recipe dependencies do not download the included bin file(zip), just the recipes #14899

Open exitingtheloop opened 1 year ago

exitingtheloop commented 1 year ago

What is your question?

Hi! I'm trying to utilize Conan's dependency handling.

I created multiple packages that don't need to compile anything, just contains a zipped bin file in each of them (included through 'exports_sources', path is same folder as recipe).

Ex: Package A (contains zipped bin file A ) Package B (contains zipped bin file B)

When I install them individually, they successfully download both the recipe and the zipped bin file. But when I make them reference each other, say Package A requires Package B (self.requires), I get the following result: -Recipe for Package B is downloaded, zipped bin file is not -Recipe and zipped bin file for Package A are both downloaded

I saw somewhere that when we don't compile the exports_sources, they wont be downloaded when included as package dependency through self.requires of a package.

Any thoughts are appreciated!

Have you read the CONTRIBUTING guide?

memsharded commented 1 year ago

Hi @exitingtheloop

If packaging existing pre-compiled binaries, the recommended approach is using conan export-pkg to avoid having an extra copy as "sources", specially if the binaries are large. Please check:

If you still decide to go with the binaries packaged initially as sources, you need to make sure those files are also copy() in the package() method. Exporting them as part of the recipe doesn't make them available to consumers, as the sources are only involved when creating the package from sources, but that doesn't happen when the final package is already existing.

exitingtheloop commented 1 year ago

Hi @memsharded ! Thanks for getting back so quickly!

Yes the zipped bin files are also being copied in the package() method through copy().

When I install a recipe that doesn't have any dependencies I'm able to get hold of the bin files by using "conan cache name/version" and it gives me the downloaded folder in the conan cache, and the bin files are on the "es/" folder.

However, when they depend on other recipes, including them in the requirements() method downloads them too, using "conan cache dependency_name/version" gives me the downloaded folder in cache too but they're missing the "es/" folder which should be containing the zipped bin files. I was aiming to do my own installation script; hence, the use of conan cache, leading to a conan install command.

memsharded commented 1 year ago

Yes, that makes sense. Please note:

Please let me know if this clarifies the issue, and how usage of Conan packages is intended.

exitingtheloop commented 1 year ago

Hi @memsharded !

I've tried the instructions here: https://docs.conan.io/2/tutorial/creating_packages/other_types_of_packages/package_prebuilt_binaries.html#packaging-already-pre-built-binaries

So far so good! I'm able to package them and include the zip files. Given that all of my packages have the same structure(where their bin files are), in which method do I define the installation steps in the recipe (actions such as unzipping the included files to a directory)?

Thank you so much

memsharded commented 1 year ago

So far so good! I'm able to package them and include the zip files. Given that all of my packages have the same structure(where their bin files are), in which method do I define the installation steps in the recipe (actions such as unzipping the included files to a directory)?

In principle the idea of using Conan is that it is not necessary. When packages are installed:

Using the files from the cache is what allows to use different versions and different binary variants from different projects simultaneously in the same machine without conflicts.

If you still want to do some system-level install, there could be a couple of different mechanisms:

exitingtheloop commented 1 year ago

Hi @memsharded , whenever I do a conan download, it brings 2 folders. 1 containing the recipe and another containing the included bin files. How do I get to this path via a deployer? since im planning to unzip them to a directory.

Thanks!

memsharded commented 1 year ago

conan download does not run deployers, but conan install does.

You can check the dependencies interface in https://docs.conan.io/2/reference/conanfile/methods/generate.html#dependencies-interface, you can see that for every package you get the recipe_folder and the package_folder.