Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Make package resolve request respect case sensitivity -- Windows #689

Merged
merged 5 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/rez/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import re
import stat
import platform


class TempDirs(object):
Expand Down Expand Up @@ -124,6 +125,23 @@ def retain_cwd():
finally:
os.chdir(cwd)

def get_case_canonical_path(path):
"""Get the packages path in the canonical case.

Paths on windows are case-insensitive therefore the filesystem package repo
filepath should be lower()ed on windows so that stuff like the unique repo identifier,
and the local path that gets stored into variant handles, doesn't differ.

Args:
path (str): Packages path to convert the case.

Returns:
str: The packages path in the canonical case form (always lowered).
"""
if "Windows" in platform.system():
return path.lower()
else:
return path

def get_existing_path(path, topmost_path=None):
"""Get the longest parent path in `path` that exists.
Expand Down
7 changes: 6 additions & 1 deletion src/rezplugins/package_repository/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import stat
import errno
import time
import platform

from rez.package_repository import PackageRepository
from rez.package_resources_ import PackageFamilyResource, VariantResourceHelper, \
Expand All @@ -20,7 +21,7 @@
from rez.utils.resources import cached_property
from rez.utils.logging_ import print_warning
from rez.utils.memcached import memcached, pool_memcached_connections
from rez.utils.filesystem import make_path_writable
from rez.utils.filesystem import make_path_writable, get_case_canonical_path
from rez.serialise import load_from_file, FileFormat
from rez.config import config
from rez.backport.lru_cache import lru_cache
Expand Down Expand Up @@ -461,6 +462,7 @@ def __init__(self, location, resource_pool):
Args:
location (str): Path containing the package repository.
"""
location = get_case_canonical_path(location)
super(FileSystemPackageRepository, self).__init__(location, resource_pool)

global _settings
Expand Down Expand Up @@ -785,6 +787,9 @@ def _get_families(self):
def _get_family(self, name):
is_valid_package_name(name, raise_error=True)
if os.path.isdir(os.path.join(self.location, name)):
# force case-sensitive match on pkg family, on case-insensitive platforms
if "Windows" in platform.system() and name not in os.listdir(self.location):
return None
family = self.get_resource(
FileSystemPackageFamilyResource.key,
location=self.location,
Expand Down