From 063aecddad96472c905edddaf8fe1ed03a37df18 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 22 Sep 2022 20:16:31 -0400 Subject: [PATCH] Use abspath() instead of resolve() in expand._assert_local() 4249da1ecf uses `pathlib.Path.resolve()` instead of `os.path.abspath()` to canonicalize path names. `resolve()` resolves symlinks, whereas `abspath()` does not. `resolve()` can also raise a `RuntimeError` if infinite loops are discovered while resolving the path. There is some concern that using `resolve()` would not be backwards compatible. This commit switches back to `abspath()` but still uses `Path.parents` to avoid the edge case. See PR #3595 for more details. --- setuptools/config/expand.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setuptools/config/expand.py b/setuptools/config/expand.py index 1497b20ca0..7a100d69c9 100644 --- a/setuptools/config/expand.py +++ b/setuptools/config/expand.py @@ -151,9 +151,7 @@ def _read_file(filepath: Union[bytes, _Path]) -> str: def _assert_local(filepath: _Path, root_dir: str): - # NOTE: Path.resolve() will raise RuntimeError if an infinite loop is - # encountered along the resolution path of root_dir or file_path. - if Path(root_dir).resolve() not in Path(filepath).resolve().parents: + if Path(os.path.abspath(root_dir)) not in Path(os.path.abspath(filepath)).parents: msg = f"Cannot access {filepath!r} (or anything outside {root_dir!r})" raise DistutilsOptionError(msg)