-os_path_relpath = getattr(os.path, 'relpath', None)
-if os_path_relpath is None:
- # Python < 2.6 does not have os.path.relpath, provide a replacement
- # (imported from Python2.6.5~rc2)
- def os_path_relpath(path, start):
- """Return a relative version of a path"""
- start_list = os.path.abspath(start).split("/")
- path_list = os.path.abspath(path).split("/")
-
- # Work out how much of the filepath is shared by start and path.
- i = len(os.path.commonprefix([start_list, path_list]))
-
- rel_list = ['..'] * (len(start_list)-i) + path_list[i:]
- if not rel_list:
- return start
- return os.path.join(*rel_list)
-
-