Esempio n. 1
0
def load_export_conanfile(conanfile_path, output):
    conanfile = load_conanfile_class(conanfile_path)

    for field in ["url", "license", "description"]:
        field_value = getattr(conanfile, field, None)
        if not field_value:
            output.warn("Conanfile doesn't have '%s'.\n"
                        "It is recommended to add it as attribute" % field)
    if getattr(conanfile, "conan_info", None):
        output.warn(
            "conan_info() method is deprecated, use package_id() instead")

    try:
        # Exports is the only object field, we need to do this, because conan export needs it
        conanfile.exports = create_exports(conanfile)
        conanfile.exports_sources = create_exports_sources(conanfile)
    except Exception as e:  # re-raise with file name
        raise ConanException("%s: %s" % (conanfile_path, str(e)))

    # check name and version were specified

    if not hasattr(conanfile, "name") or not conanfile.name:
        raise ConanException("conanfile didn't specify name")
    if not hasattr(conanfile, "version") or not conanfile.version:
        raise ConanException("conanfile didn't specify version")

    return conanfile
Esempio n. 2
0
def _load_export_conanfile(conanfile_path, output, name, version):
    conanfile = load_conanfile_class(conanfile_path)

    for field in ["url", "license", "description"]:
        field_value = getattr(conanfile, field, None)
        if not field_value:
            output.warn("Conanfile doesn't have '%s'.\n"
                        "It is recommended to add it as attribute" % field)

    try:
        # Exports is the only object field, we need to do this, because conan export needs it
        conanfile.exports = create_exports(conanfile)
        conanfile.exports_sources = create_exports_sources(conanfile)
    except Exception as e:  # re-raise with file name
        raise ConanException("%s: %s" % (conanfile_path, str(e)))

    # check name and version were specified
    if not conanfile.name:
        if name:
            conanfile.name = name
        else:
            raise ConanException("conanfile didn't specify name")
    elif name and name != conanfile.name:
        raise ConanException("Package recipe exported with name %s!=%s" % (name, conanfile.name))

    if not conanfile.version:
        if version:
            conanfile.version = version
        else:
            raise ConanException("conanfile didn't specify version")
    elif version and version != conanfile.version:
        raise ConanException("Package recipe exported with version %s!=%s"
                             % (version, conanfile.version))

    return conanfile
Esempio n. 3
0
def load_export_conanfile(conanfile_path, output):
    conanfile = load_conanfile_class(conanfile_path)

    for field in ["url", "license", "description"]:
        field_value = getattr(conanfile, field, None)
        if not field_value:
            output.warn("Conanfile doesn't have '%s'.\n"
                        "It is recommended to add it as attribute" % field)
    if getattr(conanfile, "conan_info", None):
        output.warn("conan_info() method is deprecated, use package_id() instead")

    try:
        # Exports is the only object field, we need to do this, because conan export needs it
        conanfile.exports = create_exports(conanfile)
        conanfile.exports_sources = create_exports_sources(conanfile)
    except Exception as e:  # re-raise with file name
        raise ConanException("%s: %s" % (conanfile_path, str(e)))

    # check name and version were specified

    if not hasattr(conanfile, "name") or not conanfile.name:
        raise ConanException("conanfile didn't specify name")
    if not hasattr(conanfile, "version") or not conanfile.version:
        raise ConanException("conanfile didn't specify version")

    return conanfile
Esempio n. 4
0
 def load_class(self, conanfile_path):
     """ Load only the class of the ConanFile recipe, but do not instantiate the object
     It is needed for the 'conan export' command
     """
     loaded, filename = self._parse_file(conanfile_path)
     try:
         result = self._parse_module(loaded, False, filename)
         # Exports is the only object field, we need to do this, because conan export needs it
         result.exports = create_exports(result)
         result.exports_sources = create_exports_sources(result)
         return result
     except Exception as e:  # re-raise with file name
         raise ConanException("%s: %s" % (conanfile_path, str(e)))