import pathlib
import zipfile


def _bundle(
    source_directory: pathlib.Path,
    temp_bundle_directory: pathlib.Path,
) -> pathlib.Path:
    """
    Create a bundle for the specified module in the temporary bundle directory.

    :return:
        The path to the created zip bundle.
    """
    path = temp_bundle_directory.joinpath(f"{source_directory.name}.zip")

    paths = source_directory.rglob("**/*")
    with zipfile.ZipFile(path, mode="w") as zipper:
        for p in paths:
            zipper.write(p, arcname=p.relative_to(source_directory))

    return path