def relpath(path, start='.'):
 if ((sys.version_info < (2, 7)) and ('posix' in sys.builtin_module_names)):
  if (not path):
   raise ValueError('no path specified')
  start_list = [x for x in os.path.abspath(start).split(os.path.sep) if x]
  path_list = [x for x in os.path.abspath(path).split(os.path.sep) if x]
  i = len(os.path.commonprefix([start_list, path_list]))
  rel_list = (([os.path.pardir] * (len(start_list) - i)) + path_list[i:])
  if (not rel_list):
   return os.path.curdir
  return os.path.join(*rel_list)
 return os.path.relpath(path, start=start)

def relpath ( path , start = '.' ) : if ( ( sys . version_info < ( 2 , 7 ) ) and ( 'posix' in sys . builtin_module_names ) ) : if ( not path ) : raise ValueError ( 'no path specified' ) start_list = [ x for x in os . path . abspath ( start ) . split ( os . path . sep ) if x ] path_list = [ x for x in os . path . abspath ( path ) . split ( os . path . sep ) if x ] i = len ( os . path . commonprefix ( [ start_list , path_list ] ) ) rel_list = ( ( [ os . path . pardir ] * ( len ( start_list ) - i ) ) + path_list [ i : ] ) if ( not rel_list ) : return os . path . curdir return os . path . join ( * rel_list ) return os . path . relpath ( path , start = start )
work around python bug #5117 .