def _absolute_root(path: _Path) -> str:
    """Works for packages and top-level modules"""
    path_ = Path(path)
    parent = path_.parent

    if path_.exists():
        return str(path_.resolve())
    else:
        return str(parent.resolve() / path_.name)
Works for packages and top-level modules
product/gradle-plugin/src/main/python/setuptools/command/editable_wheel.py