def make_changed_file(path, env):
    """
    Given the path to a template file, write a new file with:
        * The same filename, except without '.template' at the end.
        * A placeholder in the new file changed to the latest installable
          version of Flocker.

    This new file will be deleted on build completion.

    :param unicode path: The path to a template file.
    :param sphinx.environment.BuildEnvironment env: The Sphinx build
        environment
    """
    def remove_file(path):
        try:
            os.remove(path)
        except __HOLE__:
            pass

    latest = get_installable_version(version)
    new_path = remove_extension(path)
    with open(path, 'r') as templated_file:
        with open(new_path, 'w') as new_file:
            new_file.write(templated_file.read().replace(PLACEHOLDER, latest))
            env.app.connect('build-finished',
                            lambda self, *args: remove_file(new_path))
dataset/ETHPy150Open ClusterHQ/flocker/flocker/docs/version_extensions.py/make_changed_file