[feature] Please provide all methods in base ConanFile
See original GitHub issueCurrently, ConanFile
base class doesn’t provide methods which need to be overridden by user (for example package()
), this makes writing mixins which add different steps to “common” flow harder.
Consider example:
class MixinHeaders(ConanFile):
def package():
super().package() # < See below
self.copy("*.h")
class MixinLibraries(ConanFile):
def package():
super().package() # < See below
self.copy("*.so*");
# Consumer:
class MyConan(ConanFIle):
python_requires_extend = ["shared.MixinHeaders", "shared.MixinLibraries"]
As I understand, in order for this to work with arbitrary set of mixins all of them should call super().package()
(something called MRO involved). The problem is that for one of them super()
will be ConanFile
which doesn’t have package()
and recipe fails with AttributeError
.
To work this around I had to use something like in every mixin:
try:
super_package = getattr(super(), "package")
except AttributeError:
pass
else:
super_package()
which is bit ugly.
Maybe I get something wrong.
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Methods — conan 1.44.1 documentation
Method used to retrieve the source code from any other external origin like github using $ git clone or just a regular download....
Read more >Writing reusable base recipes for conan.io packages
Reusing the recipe is just simple python class inheritance, so all recipe methods ( source() , build() , etc) are available in your...
Read more >Conan Package Manager for C++ in Practice - YouTube
By Jerry Wiltse, presented at Core C++ [online] meetup, March 2021. The slides can be found at http://bit.ly/ConanDemo, more links to Conan ...
Read more >C/C++ Application Analysis - Sonatype Help
NEW IN RELEASE 86. The Conan coordinate-based matching feature provides the ability to scan and evaluate C/C++ dependencies found in either a conanfile.txt, ......
Read more >I want to split conafile.py into two, with both files containing ...
I have two files(conanfile.py and parent_conanfile.py). conanfile.py from conans import ConanFile, CMake from parent_conanfile import ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We introduced it because of high pressure by some users, but it is one of those features that we don’t love, because we feel that in general it adds little value (avoiding to type a couple of lines, 2 per method), but makes things more obscure (as you don’t know by reading a recipe if it is just missing a
package_info()
method, or it might be reusing an existing one from the base class, that you need to go elsewhere to read). So in that regard, it is fine that the feature is there, but we will try to limit its use as much as possible, and definitely try to limit it to simple cases.No prob, thanks for the feedback.
Ok, the
build_requires
method made more sense, as it was not defined. In any case, if you can go explicit, we believe it is better in the midterm, even if not nasty super() tricks would be necessary, with multiple inheritance many different behaviors like order of evaluations, etc can easily bite you.Thanks!