Closed MTomBosch closed 1 month ago
Hi @MTomBosch
Thanks for your question.
First, I'd like to point to the guidelines in https://docs.conan.io/2/knowledge/guidelines.html (which are basically a lesson learned valid for Conan 1.X too):
Keep
python_requires
as simple as possible. Avoid transitive python_requires, keep them as reduced as possible, and at most, require them explicitly in a “flat” structure, without python_requires requiring other python_requires. Avoid inheritance (via python_requires_extend) if not strictly necessary, and avoid multiple inheritance at all costs, as it is extremely complicated, and it does not work the same as the built-in Python one.
The explanation for this is that the python_extend
mechanism is simply not regular "static" Python inheritance. It is forced dynamically, to inject a base class that is not even in disk when the class is loaded. So the normal Python inheritance rules do not apply here, and the injection of the python-requires-extend
class happens way later in the process, after evaluating all the Python inheritance, then that base class will be injected, and it will take precedence over the others.
What is your question?
Hello, we are using Conan 1.x and are having a question related to using python_required_extend in combination with a Python recipe class hierarchy.
We are having a Conan recipe, let's call it "required_extend" where the package() function is implemened with a reasonable default behaviour.
This required_extend is used in the following recipe class hierarchy.
grand child recipe
When now running the export_pkg command on the "grandchild recipe" somehow not the package() function of the "child recipe" is called but the package() function of the "required_extend" recipe. Even defining a package() function in grandchild and calling super().package() is not working acc to my tests.
But when calling it on "child recipe" then the package() function is properly called.
Any explanation for this behaviour?
Have you read the CONTRIBUTING guide?