(source, dest, dest_is_directory=True)
return os.path.sep.join(full_parts)
Make a filename relative, where the filename is dest, and it is
    being referred to from the filename source.

        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/usr/share/another-place/src/Directory')
        '../another-place/src/Directory'
        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/home/user/src/Directory')
        '../../../home/user/src/Directory'
        >>> make_relative_path('/usr/share/a-file.pth', '/usr/share/')
        './'
Make a filename relative, where the filename is dest, and it is
    being referred to from the filename source.
Make a filename relative where the filename is dest and it is being referred to from the filename source .
def make_relative_path(source, dest, dest_is_directory=True):
    """
    Make a filename relative, where the filename is dest, and it is
    being referred to from the filename source.

        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/usr/share/another-place/src/Directory')
        '../another-place/src/Directory'
        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/home/user/src/Directory')
        '../../../home/user/src/Directory'
        >>> make_relative_path('/usr/share/a-file.pth', '/usr/share/')
        './'
    """
    source = os.path.dirname(source)
    if not dest_is_directory:
        dest_filename = os.path.basename(dest)
        dest = os.path.dirname(dest)
    dest = os.path.normpath(os.path.abspath(dest))
    source = os.path.normpath(os.path.abspath(source))
    dest_parts = dest.strip(os.path.sep).split(os.path.sep)
    source_parts = source.strip(os.path.sep).split(os.path.sep)
    while dest_parts and source_parts and dest_parts[0] == source_parts[0]:
        dest_parts.pop(0)
        source_parts.pop(0)
    full_parts = ['..']*len(source_parts) + dest_parts
    if not dest_is_directory:
        full_parts.append(dest_filename)
    if not full_parts:
        # Special case for the current directory (otherwise it'd be '')
        return './'
    return os.path.sep.join(full_parts)
def make_relative_path ( source , dest , dest_is_directory = True ) : source = os . path . dirname ( source ) if not dest_is_directory : dest_filename = os . path . basename ( dest ) dest = os . path . dirname ( dest ) dest = os . path . normpath ( os . path . abspath ( dest ) ) source = os . path . normpath ( os . path . abspath ( source ) ) dest_parts = dest . strip ( os . path . sep ) . split ( os . path . sep ) source_parts = source . strip ( os . path . sep ) . split ( os . path . sep ) while dest_parts and source_parts and dest_parts [ 0 ] == source_parts [ 0 ] : dest_parts . pop ( 0 ) source_parts . pop ( 0 ) full_parts = [ '..' ] * len ( source_parts ) + dest_parts if not dest_is_directory : full_parts . append ( dest_filename ) if not full_parts : # Special case for the current directory (otherwise it'd be '') return './' return os . path . sep . join ( full_parts )