def _create_check_conan(self, conan_file, consumer, conan_file_path, output, filename): """ Check the integrity of a given conanfile """ result = None for name, attr in conan_file.__dict__.items(): if "_" in name: continue if (inspect.isclass(attr) and issubclass(attr, ConanFile) and attr != ConanFile and attr.__dict__["__module__"] == filename): if result is None: # Actual instantiation of ConanFile object result = attr(output, self._runner, self._settings.copy(), os.path.dirname(conan_file_path)) else: raise ConanException("More than 1 conanfile in the file") if (inspect.isclass(attr) and issubclass(attr, Generator) and attr != Generator and attr.__dict__["__module__"] == filename): _save_generator(attr.__name__, attr) if result is None: raise ConanException("No subclass of ConanFile") # check name and version were specified if not consumer: if not hasattr(result, "name") or not result.name: raise ConanException("conanfile didn't specify name") if not hasattr(result, "version") or not result.version: raise ConanException("conanfile didn't specify version") return result
def _parse_module(self, conanfile_module, consumer, filename): """ Parses a python in-memory module, to extract the classes, mainly the main class defining the Recipe, but also process possible existing generators @param conanfile_module: the module to be processed @param consumer: if this is a root node in the hierarchy, the consumer project @return: the main ConanFile class from the module """ result = None for name, attr in conanfile_module.__dict__.items(): if "_" in name: continue if (inspect.isclass(attr) and issubclass(attr, ConanFile) and attr != ConanFile and attr.__dict__["__module__"] == filename): if result is None: result = attr else: raise ConanException("More than 1 conanfile in the file") if (inspect.isclass(attr) and issubclass(attr, Generator) and attr != Generator and attr.__dict__["__module__"] == filename): _save_generator(attr.__name__, attr) if result is None: raise ConanException("No subclass of ConanFile") # check name and version were specified if not consumer: if not hasattr(result, "name") or not result.name: raise ConanException("conanfile didn't specify name") if not hasattr(result, "version") or not result.version: raise ConanException("conanfile didn't specify version") return result
def _parse_module(conanfile_module, filename): """ Parses a python in-memory module, to extract the classes, mainly the main class defining the Recipe, but also process possible existing generators @param conanfile_module: the module to be processed @param consumer: if this is a root node in the hierarchy, the consumer project @return: the main ConanFile class from the module """ result = None for name, attr in conanfile_module.__dict__.items(): if "_" in name: continue if (inspect.isclass(attr) and issubclass(attr, ConanFile) and attr != ConanFile and attr.__dict__["__module__"] == filename): if result is None: result = attr else: raise ConanException("More than 1 conanfile in the file") if (inspect.isclass(attr) and issubclass(attr, Generator) and attr != Generator and attr.__dict__["__module__"] == filename): _save_generator(attr.__name__, attr) if result is None: raise ConanException("No subclass of ConanFile") return result