fix normalize path for Windows

This commit is contained in:
cjc7373 2020-04-16 20:59:03 +08:00 committed by cjc7373
parent 76b865155e
commit a9c8dc5468
2 changed files with 6 additions and 1 deletions

1
news/7625.bugfix Normal file
View File

@ -0,0 +1 @@
Fix normalizing path on Windows when installing package on another logical disk.

View File

@ -262,7 +262,11 @@ def _record_to_fs_path(record_path):
def _fs_to_record_path(path, relative_to=None):
# type: (text_type, Optional[text_type]) -> RecordPath
if relative_to is not None:
path = os.path.relpath(path, relative_to)
# On Windows, do not handle relative paths if they belong to different
# logical disks
if os.path.splitdrive(path)[0].lower() == \
os.path.splitdrive(relative_to)[0].lower():
path = os.path.relpath(path, relative_to)
path = path.replace(os.path.sep, '/')
return cast('RecordPath', path)