from pathlib import Path


def build_name(prefix: str, source_ind: int, name: Path) -> str:
    """Build a package name from the index and path."""
    if name.name.casefold() == '__init__.py':
        name = name.parent
    name = name.with_suffix('')
    dotted = str(name).replace('\\', '.').replace('/', '.')
    return f'{prefix}_{source_ind:02x}.{dotted}'