diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-10-25 20:30:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 20:30:35 -0400 |
commit | d0b88ac944944580a1ff52e0a3fda9fdbc7fb095 (patch) | |
tree | 159e016fa9297223124bb87d2d3f4c3cabd510be | |
parent | d6d9da82f6437d549ddc3d4ece0e2011abc5425a (diff) | |
parent | c14b6f35659ca0a13968632f58e18ba40cd11dca (diff) | |
download | python-setuptools-git-d0b88ac944944580a1ff52e0a3fda9fdbc7fb095.tar.gz |
Merge pull request #1335 from themiwi/patch-1
Adds call to os.path.abspath() in pkg_resources.normalize_path() on Cygwin
-rw-r--r-- | changelog.d/1335.change.rst | 1 | ||||
-rw-r--r-- | pkg_resources/__init__.py | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/changelog.d/1335.change.rst b/changelog.d/1335.change.rst new file mode 100644 index 00000000..a6ced1bb --- /dev/null +++ b/changelog.d/1335.change.rst @@ -0,0 +1 @@ +In ``pkg_resources.normalize_path``, fix issue on Cygwin when cwd contains symlinks. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 3ae2c5cd..74134701 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2228,7 +2228,18 @@ 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.realpath(_cygwin_patch(filename))) + + +def _cygwin_patch(filename): # pragma: nocover + """ + Contrary to POSIX 2008, on Cygwin, getcwd (3) contains + symlink components. Using + os.path.abspath() works around this limitation. A fix in os.getcwd() + would probably better, in Cygwin even more so, except + that this seems to be by design... + """ + return os.path.abspath(filename) if sys.platform == 'cygwin' else filename def _normalize_cached(filename, _cache={}): |