def _label_to_path(label):
    """
    Given a Label, turn it into a path by keeping the directory part of the
    name, and attaching that to the package path.
    """

    base = label.package

    name = label.name

    last_slash = name.rfind("/")
    if last_slash >= 0:
        base = "{}/{}".format(base, name[0:last_slash])

    return base