Conan: Add an option to prefix a package direcotry name with a user specified string.

Created on 12 Oct 2018  路  8Comments  路  Source: conan-io/conan

As the names of the package folders in the package sub directory in the Conan data directory contain only the hash, it is difficult to navigate to the right one which you need for some reason. To find the folder of the package in which I'm interested, I have to check conaninfo.txt file in the folder and when I have to many packages in the same folder this becomes messy very fast. It will be good if in the recipe can be specified some user defined prefix for the package folder. For example in it the creator of the package can add some of the settings and options of the library contained in the package and/or the build time. The format can be <user_defined_prefix>_<package_hash>. For example:

windows_msvc15_x64_release_shared_20181110164553_ee3c193ac1401f4d5e7227f5133036acb9685bb8
linux_gcc72_x86_debug_static_20181210101723_67ded42f1cdd2ab31483899d916e2fef5dc649f8

Here for the prefix I'm using <os>_<compiler>_<arch>_<build_type>_<static or shared lib>_<datetime>, but this format can be entirely user specific and still the package will be uniquely identified by its hash.

Most helpful comment

No problem. I have no detailed knowledge about the inner structure of Conan, and because of this I don't understand why this is "extremely difficult", but maybe I can try someday in the future to do some investigation about this and to try to implement it by myself. Thank you for your time and for the suggestions how to avoid the need for such a feature.

All 8 comments

I don't think this is something you need to specify. Package IDs are part of the Conan model as a way to make unique identifiers for each package. On every package creation command (conan create, conan export-pkg) the ID of the package created is displayed.

You can the use conan search to get the package ID for each package in your cache or in remotes:

$ conan search zlib/1.2.11@conan/stable
Existing packages for recipe zlib/1.2.11@conan/stable:

    Package_ID: 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
        [options]
            shared: False
        [settings]
            arch: x86_64
            build_type: Release
            compiler: Visual Studio
            compiler.runtime: MD
            compiler.version: 15
            os: Windows
        Outdated from recipe: False

Could you explain your use case? Why do you need to identify packages by looking inside their folders?
Thanks! 馃槃

You can the use conan search to get the package ID for each package in your cache or in remotes

Thank you for the suggestion. Really this way is better than looking into conaninfo.txt in each folder, but I still think that it will be even easier, if I can spot what I need directly in the file manager instead of executing additional command from the command prompt, and searching for the hash in the package directory. And looking in the package directory is something which I do frequently when creating a new recipe in order to check that everything is in place whether it is intended to be.

Why do you need to find the packages manually by exploring the folders? Maybe we are missing a use case.

@lasote Because in some cases I find it easier, instead of executing additional command. Other package managers like Nix supports additional tags after the package hash. I personally prefer prefixes instead suffixes, but it is possible optionally to support both of them.

For example: [<prefix>_]<package_hash>[-<suffix>]. Here I'm using _underscore_ for prefix separator and _dash_ as suffix separator, because if someone uses only suffix or prefix and uses a valid hash for it (being entirely user defined), it will not be possible to uniquely identify which is the prefix/suffix and which is the actual hash.

I understand @bobeff. But why do you need to identify the packages in the local cache? Usually the only thing you need is "conan install" with a profile, if it is there it will use it, otherwise, it will fail, but it is a black box. I understand that prefixing the packages would be easier to know that you have inside them, but the question is, why do you need to know it?

Yes, as I already wrote, when creating a new recipe I have to frequently look at the exported package to check that everything is on the right place and nothing is missing.

I see, sorry I missed. Now I get it, thanks for your time.
I'm sorry but doing such a feature would be extremely difficult.
I can recommend:

  • If you are using a "conan create" command the package path is printed in the output. You can check the path at that moment.
  • If you are developing the recipe, the best way to do it is using the conan local methods. So, everything is built in local directories until you verify that everything is ok: https://docs.conan.io/en/latest/developing_packages/package_dev_flow.html

No problem. I have no detailed knowledge about the inner structure of Conan, and because of this I don't understand why this is "extremely difficult", but maybe I can try someday in the future to do some investigation about this and to try to implement it by myself. Thank you for your time and for the suggestions how to avoid the need for such a feature.

Was this page helpful?
0 / 5 - 0 ratings