<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_changelog(project_dir=os.curdir, bugtracker_url='', rpm_format=False):
 """ Creates the changelog file, if not in a package. :param project_dir: Path to the git repo of the project. :type project_dir: str :param bugtracker_url: Url to the bug tracker for the issues. :type bugtracker_url: str :param rpm_format: if set to True, will make the changelog rpm-compatible. :type rpm_format: bool :rises RuntimeError: If the changelog could not be retrieved """

    pkg_info_file = os.path.join(project_dir, 'PKG-INFO')
    if os.path.exists(pkg_info_file):
        return

    with open('CHANGELOG', 'wb') as changelog_fd:
        changelog_fd.write(
            get_changelog(
                project_dir=project_dir,
                bugtracker_url=bugtracker_url,
                rpm_format=rpm_format,
            ).encode('utf-8')
        )