Return the relative path of a file or directory, specified
    as ``path`` relative to (the parent directory of) ``from_file``.

    This method is intented to be called with ``__file__``
    as second argument.

    The returned path is relative to the current working directory.

    If ``path`` is ``None``, return ``None``.

    Example: ::

        path="res/foo.bar"
        from_file="/root/abc/def/ghi.py"
        cwd="/root"
        => "abc/def/res/foo.bar"

    :param string path: the file path
    :param string from_file: the reference file
    :rtype: string

def relative_path(path, from_file):
    """
    Return the relative path of a file or directory, specified
    as ``path`` relative to (the parent directory of) ``from_file``.

    This method is intented to be called with ``__file__``
    as second argument.

    The returned path is relative to the current working directory.

    If ``path`` is ``None``, return ``None``.

    Example: ::

        path="res/foo.bar"
        from_file="/root/abc/def/ghi.py"
        cwd="/root"
        => "abc/def/res/foo.bar"

    :param string path: the file path
    :param string from_file: the reference file
    :rtype: string
    """
    if path is None:
        return None
    abs_path_target = absolute_path(path, from_file)
    abs_path_cwd = os.getcwd()
    if is_windows():
        # NOTE on Windows, if the two paths are on different drives,
        #      the notion of relative path is not defined:
        #      return the absolute path of the target instead.
        t_drive, t_tail = os.path.splitdrive(abs_path_target)
        c_drive, c_tail = os.path.splitdrive(abs_path_cwd)
        if t_drive != c_drive:
            return abs_path_target
    return os.path.relpath(abs_path_target, start=abs_path_cwd)