import shutil, os


def ensure_copy(src, dest):
    """Copy src into dest.

    Guarantees that the file indicated by ``dest`` is a copy of the file ``src``

    Args:
      src (str): path of the source file. Should be valid.
      dest (src): path of the destination file

    Returns:
      bool: ``True`` if the file needed to be copied, ``False`` if ``src``
         and ``dest`` are identical
    """
    copied = False
    if (os.path.isfile(dest) and os.stat(dest) != os.stat(src)) or not os.path.isfile(dest):
        shutil.copy2(src, os.path.dirname(dest))
        copied = True
    return copied