def safe_mkdir(path):
    """
    Creates the directory, including any missing parent directories, at the
    specified `path`.

    Aborts if the path points to an existing regular file.

    Returns the absolute path of the directory.
    """
    if os.path.isfile(path):
        die("'{0}' is a regular file: can't overwrite" % path)
    elif os.path.isdir(path):
        info("directory '%s' already exists" % path)
    else:
        info("creating directory '%s'" % path)
        try:
            os.makedirs(path)
        except OSError as e:
            die("""failed to recursively create the directory
%s
%s
  Do you have write permision to that path?
  Or does part of that path already exist as a regular file?""" % (path, e))
    return os.path.abspath(path)