def create_package(conanfile, build_folder, package_folder, output):
    """ copies built artifacts, libs, headers, data, etc from build_folder to
    package folder
    """
    mkdir(package_folder)

    # Make the copy of all the patterns
    output.info("Generating the package")
    output.info("Package folder %s" % (package_folder))
    conanfile.copy = FileCopier(build_folder, package_folder)

    def wrap(dst_folder):
        def new_method(pattern, src=""):
            conanfile.copy(pattern, dst_folder, src)
        return new_method

    conanfile.copy_headers = wrap(DEFAULT_INCLUDE)
    conanfile.copy_libs = wrap(DEFAULT_LIB)
    conanfile.copy_bins = wrap(DEFAULT_BIN)
    conanfile.copy_res = wrap(DEFAULT_RES)
    try:
        conanfile.package_folder = package_folder
        conanfile.package()
        package_output = ScopedOutput("%s package()" % output.scope, output)
        conanfile.copy.report(package_output, warn=True)
    except Exception as e:
        os.chdir(build_folder)
        try:
            rmdir(package_folder)
        except Exception as e_rm:
            output.error("Unable to remove package folder %s\n%s"
                                    % (package_folder, str(e_rm)))
            output.warn("**** Please delete it manually ****")
        raise ConanException("%s: %s" % (conanfile.name, str(e)))

    _create_aux_files(build_folder, package_folder)
    output.success("Package '%s' created" % os.path.basename(package_folder))
dataset/ETHPy150Open conan-io/conan/conans/client/packager.py/create_package/original