conan-io / hooks

Official Conan client hooks
MIT License
33 stars 46 forks source link

Remove `conandata.yml` field limits #530

Closed AbrilRBS closed 8 months ago

AbrilRBS commented 8 months ago

This will allow to have an extra fields in the conandata.yml file, which is meant to contain things that the recipes use on a per version basis. ie, wasmtime-cpp (Among many others) contains a version mapping inside the recipe, so every time a new version is added, the revisions of every other version also get modified (https://github.com/conan-io/conan-center-index/pull/23172/files#diff-1a9d4053acc279660d5b2b73ca7f473b969b33b25621bdad9465c9da9f84fd65R47)

This allows the trim_conandata hook to keep the old revisions for older versions :)

Note that we'll be conservative when allowing these fields in PR reviews, so a good reason might need to be provided in order for us to accept these if its usage falls outside the example shown below

The idea is to move those kinds of mappings from

version_map = {
            "0.35.0": "0.35.1",
            "0.39.0": "0.39.1",
            "1.0.0": "1.0.1",
            "6.0.0": "6.0.1",
            "9.0.0": "12.0.2",
            "18.0.0": "18.0.3",
        }
selected = version_map[self.version]

to conandata.yml

"extra":
   "0.35.0":
      "requirement": "0.35.1"
   "0.39.0":
      "requirement": "0.39.1"
   "1.0.0":
      "requirement": "1.0.1"
   "6.0.0":
      "requirement": "6.0.1"
   "9.0.0":
      "requirement": "12.0.2"
   "18.0.0":
      "requirement": "18.0.3"

conanfile.py

selected = self.conan_data.get("extra")[self.version]["requirement"]

or similar :)

uilianries commented 8 months ago

@RubenRBS Would be possible to name the package reference instead? I looked the yaml first, without reading the description, with no context, I really didn't get the idea. My point is trying to make the yaml clear without needed to search in docs about the format or what is it about.

Could it be:

sources:
  ...

patches:
  ...

requirements:
    "0.35.0":
      - "wasmtime/0.35.1"

So, we could:

def requirements(self):
    for requirement in self.conan_data.get("requirements")[self.version]:
        self.requires(requirement)

# Now we move all dependencies from conanfile.pys in CCI to conandata.yml #joke

Of course, it could result in users abusing of it, instead of using conanfile.py. But we know it's for a specific case.