from typing import List
import textwrap


def generate_build_file_contents(name: str, dependencies: List[str]) -> str:
    """Generate a BUILD file for an unzipped Wheel

    Args:
        name: the target name of the py_library
        dependencies: a list of Bazel labels pointing to dependencies of the library

    Returns:
        A complete BUILD file as a string
    """

    return textwrap.dedent(
        """\
        package(default_visibility = ["//visibility:public"])

        load("@rules_python//python:defs.bzl", "py_library")

        py_library(
            name = "{name}",
            srcs = glob(["**/*.py"]),
            data = glob(["**/*"], exclude=["**/*.py", "**/* *", "BUILD", "WORKSPACE"]),
            # This makes this directory a top-level in the python import
            # search path for anything that depends on this.
            imports = ["."],
            deps = [{dependencies}],
        )
        """.format(
            name=name, dependencies=",".join(dependencies)
        )
    )