from typing import Union
from pathlib import Path


def get_module_from_path(path: Union[Path, str], package_root: Union[Path, str]) -> str:
    """
    Converts the path within the package_root to a full module name starting with the package.
    """
    path = Path(path).resolve()
    root = Path(package_root).resolve()
    parts = list(path.parent.relative_to(root.parent).parts)
    if path.stem != '__init__':
        parts.append(path.stem)
    module = '.'.join(parts)
    return module