Skip to content

Commit

Permalink
Use the built in support for os.path.samefile
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Mar 18, 2017
1 parent 28d4954 commit 23b03de
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
12 changes: 1 addition & 11 deletions pip/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

__all__ = [
"ipaddress", "uses_pycache", "console_to_str", "native_str",
"get_path_uid", "stdlib_pkgs", "WINDOWS", "samefile",
"get_path_uid", "stdlib_pkgs", "WINDOWS",
]


Expand Down Expand Up @@ -111,13 +111,3 @@ def expanduser(path):
# windows detection, covers cpython and ironpython
WINDOWS = (sys.platform.startswith("win") or
(sys.platform == 'cli' and os.name == 'nt'))


def samefile(file1, file2):
"""Provide an alternative for os.path.samefile on Windows/Python2"""
if hasattr(os.path, 'samefile'):
return os.path.samefile(file1, file2)
else:
path1 = os.path.normcase(os.path.abspath(file1))
path2 = os.path.normcase(os.path.abspath(file2))
return path1 == path2
3 changes: 1 addition & 2 deletions pip/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import tempfile
import os.path

from pip.compat import samefile
from pip.exceptions import BadCommand
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request
Expand Down Expand Up @@ -238,7 +237,7 @@ def _get_subdirectory(self, location):
)
return None
# relative path of setup.py to repo root
if samefile(root_dir, location):
if os.path.samefile(root_dir, location):
return None
return os.path.relpath(location, root_dir)

Expand Down

0 comments on commit 23b03de

Please sign in to comment.