def create_executable_script(filepath, body, program=None):
program = program or "<STR_LIT>"<EOL>if callable(body):<EOL><INDENT>from rez.utils.sourcecode import SourceCode<EOL>code = SourceCode(func=body)<EOL>body = code.source<EOL><DEDENT>if not body.endswith('<STR_LIT:\n>'):<EOL><INDENT>body += '<STR_LIT:\n>'<EOL><DEDENT>with open(filepath, '<STR_LIT:w>') as f:<EOL><INDENT>f.write("<STR_LIT>" % program)<EOL>f.write(body)<EOL><DEDENT>if os.name == "<STR_LIT>":<EOL><INDENT>os.chmod(filepath, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH<EOL>| stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)<EOL><DEDENT>
Create an executable script.

    Args:
        filepath (str): File to create.
        body (str or callable): Contents of the script. If a callable, its code
            is used as the script body.
        program (str): Name of program to launch the script, 'python' if None