[question] Conan 2.0 Custom Generators
See original GitHub issueI have a few custom generators that help support pre-conan setups, defining extra environment variables and such. I am attempting to upgrade these to conan 2.0, but it appears that custom generators are not supported in conan 2.0. Looking at conans/client/loader.py
, it requires all custom generators to be a subclass of conans.model.conan_file.Generator
but the 2.0 generators (like VirtualRunEnv) don’t use that base class.
Presently, if a user wants to use this custom generator, then they run a command such as
conan install package/version@ -g my_generator
I asked on the slack page and was told that custom generators are planned to go away in conan 2.0. Is there a way to produce the above behavior in conan 2.0. I know that I could include a generator in the conanfile, but it is only needed in certain circumstances and its use is orthogonal to the recipe.
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (7 by maintainers)
I have added a test in https://github.com/conan-io/conan/pull/11605 to illustrate how this can be done. Basically, use Python flexibility:
We can put the
python_require
in the way it belongs, in theTool(ConanFile)
, but make it available to different parts of the classes and functions to be reused.There is no explicit examples, but there exist docs for
python_requires
in https://docs.conan.io/en/latest/extending/python_requires.html.The approach to use
python_requires
to implement a generator is basically (code not tested, just the idea):python_require
, something like: