diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2018-10-24 09:52:56 +0800 |
---|---|---|
committer | Tzu-ping Chung <uranusjr@gmail.com> | 2018-10-25 00:36:03 +0800 |
commit | 84f1abafd3a707b464f039892ef48b9e282d0d4a (patch) | |
tree | e8d1242183c0b4ca431b8426cf173c66e60d0d23 | |
parent | 8c22c3b5ac0a5a293b03b79686e53f885d71cba4 (diff) | |
download | external_python_setuptools-84f1abafd3a707b464f039892ef48b9e282d0d4a.tar.gz external_python_setuptools-84f1abafd3a707b464f039892ef48b9e282d0d4a.tar.bz2 external_python_setuptools-84f1abafd3a707b464f039892ef48b9e282d0d4a.zip |
Call os.path.normpath to normalize paths for comp
-rw-r--r-- | changelog.d/1519.change.rst | 1 | ||||
-rw-r--r-- | pkg_resources/__init__.py | 2 | ||||
-rw-r--r-- | pkg_resources/tests/test_pkg_resources.py | 5 |
3 files changed, 7 insertions, 1 deletions
diff --git a/changelog.d/1519.change.rst b/changelog.d/1519.change.rst new file mode 100644 index 00000000..d6da88be --- /dev/null +++ b/changelog.d/1519.change.rst @@ -0,0 +1 @@ +Perform additional path normalization to ensure path values to a directory is always the same, preventing false positives when checking scripts have a consistent prefix to set up on Windows. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 3ae2c5cd..2b2442f5 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2228,7 +2228,7 @@ register_namespace_handler(object, null_ns_handler) def normalize_path(filename): """Normalize a file/dir name for comparison purposes""" - return os.path.normcase(os.path.realpath(filename)) + return os.path.normcase(os.path.normpath(os.path.realpath(filename))) def _normalize_cached(filename, _cache={}): diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py index 62a39b8f..81b67a31 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -236,3 +236,8 @@ class TestDeepVersionLookupDistutils: req = pkg_resources.Requirement.parse('foo>=1.9') dist = pkg_resources.WorkingSet([env.paths['lib']]).find(req) assert dist.version == version + + def test_normalize_path(self, tmpdir): + path = str(tmpdir) + expected = os.path.normcase(os.path.normpath(os.path.realpath(path))) + assert pkg_resources.normalize_path(path) == expected |