def RealToRelative(filepath, basepath):
  """Returns a relative path from an absolute basepath and filepath."""
  path_parts = filepath.split('/')
  base_parts = basepath.split('/')
  while path_parts and base_parts and path_parts[0] == base_parts[0]:
    path_parts = path_parts[1:]
    base_parts = base_parts[1:]
  rel_parts = ['..'] * len(base_parts) + path_parts
  return '/'.join(rel_parts)