def get_script_header(script_text, executable=sys_executable, wininst=False):
from distutils.command.build_scripts import first_line_re<EOL>if not isinstance(first_line_re.pattern, str):<EOL><INDENT>first_line_re = re.compile(first_line_re.pattern.decode())<EOL><DEDENT>first = (script_text+'<STR_LIT:\n>').splitlines()[<NUM_LIT:0>]<EOL>match = first_line_re.match(first)<EOL>options = '<STR_LIT>'<EOL>if match:<EOL><INDENT>options = match.group(<NUM_LIT:1>) or '<STR_LIT>'<EOL>if options: options = '<STR_LIT:U+0020>'+options<EOL><DEDENT>if wininst:<EOL><INDENT>executable = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>executable = nt_quote_arg(executable)<EOL><DEDENT>hdr = "<STR_LIT>" % locals()<EOL>if not isascii(hdr):<EOL><INDENT>if options:<EOL><INDENT>if options.strip().startswith('<STR_LIT:->'):<EOL><INDENT>options = '<STR_LIT>'+options.strip()[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>options = '<STR_LIT>'<EOL><DEDENT><DEDENT>executable = fix_jython_executable(executable, options)<EOL>hdr = "<STR_LIT>" % locals()<EOL>return hdr<EOL>
Create a #! line, getting options (if any) from script_text