code: def copyfile_atomic(source_path, dest_path, make_parents=False, backup_suffix=None):
    
    with atomic_output_file(dest_path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path:
      shutil.copyfile(source_path, tmp_path)
      set_file_mtime(tmp_path, os.path.getmtime(source_path))
docs: Copy file on local filesystem in an atomic way, so partial copies never exist. Preserves timestamps.