<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def recipe(package, repository=None, depends_on=None, release=False, output_path=None, auto=False, overwrite=False, name=None):
 """Create a new upgrade recipe, for developers."""

    upgrader = InvenioUpgrader()
    logger = upgrader.get_logger()

    try:
        path, found_repository = _upgrade_recipe_find_path(package)

        if output_path:
            path = output_path

        if not repository:
            repository = found_repository

        if not os.path.exists(path):
            raise RuntimeError("Path does not exists: %s" % path)
        if not os.path.isdir(path):
            raise RuntimeError("Path is not a directory: %s" % path)

        # Generate upgrade filename
        if release:
            filename = "%s_release_x_y_z.py" % repository
        else:
            filename = "%s_%s_%s.py" % (repository,
                                        date.today().strftime("%Y_%m_%d"),
                                        name or 'rename_me')

        # Check if generated repository name can be parsed
        test_repository = upgrader._parse_plugin_id(filename[:-3])
        if repository != test_repository:
            raise RuntimeError(
                "Generated repository name cannot be parsed. "
                "Please override it with --repository option."
            )

        upgrade_file = os.path.join(path, filename)

        if os.path.exists(upgrade_file) and not overwrite:
                raise RuntimeError(
                    "Could not generate upgrade - %s already exists."
                    % upgrade_file
                )

        # Determine latest installed upgrade
        if depends_on is None:
            depends_on = ["CHANGE_ME"]

            u = upgrader.latest_applied_upgrade(repository=repository)
            if u:
                depends_on = [u]

        # Write upgrade template file
        _write_template(
            upgrade_file, name or 'rename_me',
            depends_on, repository, auto=auto)

        logger.info("Created new upgrade %s" % upgrade_file)
    except RuntimeError as e:
        for msg in e.args:
            logger.error(unicode(msg))
        raise