Search code examples
pythonyamlconan

How to populate conandata.yml?


Is there any way to write anything to conandata.yml file? I want calculate execution time of code and populate my conandata.yml with it.


Solution

  • There is the update_conandata() that you can use in your export() method:

    import os
    from conan import ConanFile
    from conan.tools.files import update_conandata
    
    
    class Pkg(ConanFile):
        name = "pkg"
        version = "0.1"
    
        def export(self):
            update_conandata(self, {"mydata": {...}})
    

    However I am not sure this is a good practice. Conan packages should be reproducible, and conan create . should result in always the same conandata. The conandata.yml is a place to store information that is source for the recipe to work, not to store arbitrary metadata about the code or other stuff, so it sounds abuse of the conandata feature.