diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-06-21 11:09:22 +0100 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-06-21 11:37:13 +0100 |
| commit | fd5fcbb1ec200ba2b0c657628a591ce2255998e3 (patch) | |
| tree | e4c20ee26e15647978b9f0102d8d27d11197840a /setuptools/_path.py | |
| parent | fd891afb3020eceab6d8528dfbc0d844865361d4 (diff) | |
| download | python-setuptools-git-fd5fcbb1ec200ba2b0c657628a591ce2255998e3.tar.gz | |
build_meta: Allow dist-info and egg-info to coexist
PEP 517 does not care if other directories/files are left behind in the
`metadata_directory`, as long as a `.dist_info` directory is produced at
the root. We can leave the `.egg-info` directory behind, so this way
we don't have to run it again when listing files from `build_py`.
Diffstat (limited to 'setuptools/_path.py')
| -rw-r--r-- | setuptools/_path.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/setuptools/_path.py b/setuptools/_path.py index ede9cb00..3767523b 100644 --- a/setuptools/_path.py +++ b/setuptools/_path.py @@ -1,7 +1,29 @@ import os +from typing import Union + +_Path = Union[str, os.PathLike] def ensure_directory(path): """Ensure that the parent directory of `path` exists""" dirname = os.path.dirname(path) os.makedirs(dirname, exist_ok=True) + + +def same_path(p1: _Path, p2: _Path) -> bool: + """Differs from os.path.samefile because it does not require paths to exist. + Purely string based (no comparison between i-nodes). + >>> same_path("a/b", "./a/b") + True + >>> same_path("a/b", "a/./b") + True + >>> same_path("a/b", "././a/b") + True + >>> same_path("a/b", "./a/b/c/..") + True + >>> same_path("a/b", "../a/b/c") + False + >>> same_path("a", "a/b") + False + """ + return os.path.normpath(p1) == os.path.normpath(p2) |
