Esempio n. 1
0
def export_pkg(cache, graph_manager, hook_manager, recorder, output,
               ref, source_folder, build_folder, package_folder, install_folder,
               graph_info, force, remotes):

    conan_file_path = cache.package_layout(ref).conanfile()
    if not os.path.exists(conan_file_path):
        raise ConanException("Package recipe '%s' does not exist" % str(ref))

    # The graph has to be loaded with build_mode=[ref.name], so that node is not tried
    # to be downloaded from remotes
    deps_graph, _ = graph_manager.load_graph(ref, None, graph_info=graph_info, build_mode=[ref.name],
                                             check_updates=False, update=False,
                                             remotes=remotes, recorder=recorder,
                                             apply_build_requires=False)
    # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
    # which is the exported pkg
    nodes = deps_graph.root.neighbors()
    conanfile = nodes[0].conanfile
    from conans.client.conan_api import existing_info_files
    if install_folder and existing_info_files(install_folder):
        load_deps_info(install_folder, conanfile, required=True)
    package_id = nodes[0].package_id
    output.info("Packaging to %s" % package_id)
    pref = PackageReference(ref, package_id)
    layout = cache.package_layout(ref, short_paths=conanfile.short_paths)
    dest_package_folder = layout.package(pref)

    if os.path.exists(dest_package_folder):
        if force:
            rmdir(dest_package_folder)
        else:
            raise ConanException("Package already exists. Please use --force, -f to "
                                 "overwrite it")

    recipe_hash = layout.recipe_manifest().summary_hash
    conanfile.info.recipe_hash = recipe_hash
    conanfile.develop = True
    if package_folder:
        packager.export_pkg(conanfile, package_id, package_folder, dest_package_folder,
                            hook_manager, conan_file_path, ref)
    else:
        with get_env_context_manager(conanfile):
            packager.create_package(conanfile, package_id, source_folder, build_folder,
                                    dest_package_folder, install_folder, hook_manager,
                                    conan_file_path, ref, local=True)

    readed_manifest = FileTreeManifest.load(dest_package_folder)
    pref = PackageReference(pref.ref, pref.id, readed_manifest.summary_hash)
    output.info("Package revision %s" % pref.revision)
    with layout.update_metadata() as metadata:
        metadata.packages[package_id].revision = pref.revision
        metadata.packages[package_id].recipe_revision = metadata.recipe.revision

    recorder.package_exported(pref)
Esempio n. 2
0
def export_pkg(client_cache, graph_manager, hook_manager, recorder, output,
               reference, source_folder, build_folder, package_folder,
               install_folder, graph_info, force):

    conan_file_path = client_cache.conanfile(reference)
    if not os.path.exists(conan_file_path):
        raise ConanException("Package recipe '%s' does not exist" %
                             str(reference))

    deps_graph = graph_manager.load_simple_graph(reference, graph_info.profile,
                                                 recorder)

    # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
    # which is the exported pkg
    nodes = deps_graph.root.neighbors()
    conanfile = nodes[0].conanfile
    from conans.client.conan_api import existing_info_files
    if install_folder and existing_info_files(install_folder):
        load_deps_info(install_folder, conanfile, required=True)
    pkg_id = conanfile.info.package_id()
    output.info("Packaging to %s" % pkg_id)
    pkg_reference = PackageReference(reference, pkg_id)
    dest_package_folder = client_cache.package(
        pkg_reference, short_paths=conanfile.short_paths)

    if os.path.exists(dest_package_folder):
        if force:
            rmdir(dest_package_folder)
        else:
            raise ConanException(
                "Package already exists. Please use --force, -f to "
                "overwrite it")

    recipe_hash = client_cache.load_manifest(reference).summary_hash
    conanfile.info.recipe_hash = recipe_hash
    conanfile.develop = True
    package_output = ScopedOutput(str(reference), output)
    if package_folder:
        packager.export_pkg(conanfile, pkg_id, package_folder,
                            dest_package_folder, package_output, hook_manager,
                            conan_file_path, reference)
    else:
        packager.create_package(conanfile,
                                pkg_id,
                                source_folder,
                                build_folder,
                                dest_package_folder,
                                install_folder,
                                package_output,
                                hook_manager,
                                conan_file_path,
                                reference,
                                local=True)
    recorder.package_exported(pkg_reference)
Esempio n. 3
0
def export_pkg(app, recorder, full_ref, source_folder, build_folder, package_folder, install_folder,
               graph_info, force, remotes):
    ref = full_ref.copy_clear_rev()
    cache, output, hook_manager = app.cache, app.out, app.hook_manager
    graph_manager = app.graph_manager
    conan_file_path = cache.package_layout(ref).conanfile()
    if not os.path.exists(conan_file_path):
        raise ConanException("Package recipe '%s' does not exist" % str(ref))

    # The graph has to be loaded with build_mode=[ref.name], so that node is not tried
    # to be downloaded from remotes
    deps_graph = graph_manager.load_graph(ref, None, graph_info=graph_info, build_mode=[ref.name],
                                          check_updates=False, update=False, remotes=remotes,
                                          recorder=recorder, apply_build_requires=False)
    # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
    # which is the exported pkg
    nodes = deps_graph.root.neighbors()
    conanfile = nodes[0].conanfile
    from conans.client.conan_api import existing_info_files
    if install_folder and existing_info_files(install_folder):
        load_deps_info(install_folder, conanfile, required=True)
    package_id = nodes[0].package_id
    output.info("Packaging to %s" % package_id)
    pref = PackageReference(ref, package_id)
    layout = cache.package_layout(ref, short_paths=conanfile.short_paths)
    dest_package_folder = layout.package(pref)

    if os.path.exists(dest_package_folder):
        if force:
            rmdir(dest_package_folder)
        else:
            raise ConanException("Package already exists. Please use --force, -f to "
                                 "overwrite it")

    recipe_hash = layout.recipe_manifest().summary_hash
    conanfile.info.recipe_hash = recipe_hash
    conanfile.develop = True
    if package_folder:
        prev = packager.export_pkg(conanfile, package_id, package_folder, dest_package_folder,
                                   hook_manager, conan_file_path, ref)
    else:
        with get_env_context_manager(conanfile):
            prev = packager.run_package_method(conanfile, package_id, source_folder, build_folder,
                                               dest_package_folder, install_folder, hook_manager,
                                               conan_file_path, ref, local=True)

    packager.update_package_metadata(prev, layout, package_id, full_ref.revision)
    pref = PackageReference(pref.ref, pref.id, prev)
    if graph_info.graph_lock:
        # after the package has been created we need to update the node PREV
        nodes[0].prev = pref.revision
        graph_info.graph_lock.update_check_graph(deps_graph, output)
    recorder.package_exported(pref)
Esempio n. 4
0
def export_pkg(app, recorder, full_ref, source_folder, build_folder,
               package_folder, install_folder, graph_info, force, remotes):
    ref = full_ref.copy_clear_rev()
    cache, output, hook_manager = app.cache, app.out, app.hook_manager
    graph_manager = app.graph_manager
    conan_file_path = cache.package_layout(ref).conanfile()
    if not os.path.exists(conan_file_path):
        raise ConanException("Package recipe '%s' does not exist" % str(ref))

    # The graph has to be loaded with build_mode=[ref.name], so that node is not tried
    # to be downloaded from remotes
    # passing here the create_reference=ref argument is useful so the recipe is in "develop",
    # because the "package()" method is in develop=True already
    deps_graph = graph_manager.load_graph(ref,
                                          ref,
                                          graph_info=graph_info,
                                          build_mode=[ref.name],
                                          check_updates=False,
                                          update=False,
                                          remotes=remotes,
                                          recorder=recorder,
                                          apply_build_requires=False)
    # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
    # which is the exported pkg
    nodes = deps_graph.root.neighbors()
    pkg_node = nodes[0]
    conanfile = pkg_node.conanfile

    def _init_conanfile_infos():
        node_order = [
            n for n in pkg_node.public_closure if n.binary != BINARY_SKIP
        ]
        subtree_libnames = [node.ref.name for node in node_order]
        add_env_conaninfo(conanfile, subtree_libnames)

    _init_conanfile_infos()
    from conans.client.conan_api import existing_info_files
    if install_folder and existing_info_files(install_folder):
        load_deps_info(install_folder, conanfile, required=True)
    package_id = pkg_node.package_id
    output.info("Packaging to %s" % package_id)
    pref = PackageReference(ref, package_id)
    layout = cache.package_layout(ref, short_paths=conanfile.short_paths)

    if layout.package_id_exists(package_id) and not force:
        raise ConanException(
            "Package already exists. Please use --force, -f to overwrite it")

    layout.package_remove(pref)

    dest_package_folder = layout.package(pref)
    recipe_hash = layout.recipe_manifest().summary_hash
    conanfile.info.recipe_hash = recipe_hash
    conanfile.develop = True
    with layout.set_dirty_context_manager(pref):
        if package_folder:
            prev = packager.export_pkg(conanfile, package_id, package_folder,
                                       dest_package_folder, hook_manager,
                                       conan_file_path, ref)
        else:
            prev = run_package_method(conanfile, package_id, source_folder,
                                      build_folder, dest_package_folder,
                                      install_folder, hook_manager,
                                      conan_file_path, ref)

    packager.update_package_metadata(prev, layout, package_id,
                                     full_ref.revision)
    pref = PackageReference(pref.ref, pref.id, prev)
    if pkg_node.graph_lock_node:
        # after the package has been created we need to update the node PREV
        pkg_node.prev = pref.revision
        pkg_node.graph_lock_node.prev = pref.revision
    recorder.package_exported(pref)