aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--changelog.d/1519.change.rst1
-rw-r--r--pkg_resources/__init__.py2
-rw-r--r--pkg_resources/tests/test_pkg_resources.py5
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