How to get dependency include & library directories in Conanfile.py

Within conanfile.py , this is how you can obtain a list of include & library directories for each of the dependencies:

class MyProject(Conanfile):
    # ...
    def build(self):
        # Check dependencies
        for dependency in self.dependencies.values():
            cppinfo = dependency.cpp_info.aggregated_components()
            print("libdirs", cppinfo.libdirs)
            print("includedirs", cppinfo.includedirs)
        # ...