def get_script_header(script_text, executable=sys_executable, wininst=False):
 from distutils.command.build_scripts import first_line_re
 first = (script_text + '\n').splitlines()[0]
 match = first_line_re.match(first)
 options = ''
 if match:
  options = (match.group(1) or '')
  if options:
   options = (' ' + options)
 if wininst:
  executable = 'python.exe'
 else:
  executable = nt_quote_arg(executable)
 hdr = ('#!%(executable)s%(options)s\n' % locals())
 if (unicode(hdr, 'ascii', 'ignore').encode('ascii') != hdr):
  if options:
   if options.strip().startswith('-'):
    options = (' -x' + options.strip()[1:])
  else:
   options = ' -x'
 executable = fix_jython_executable(executable, options)
 hdr = ('#!%(executable)s%(options)s\n' % locals())
 return hdr

def get_script_header ( script_text , executable = sys_executable , wininst = False ) : from distutils . command . build_scripts import first_line_re first = ( script_text + '\n' ) . splitlines ( ) [ 0 ] match = first_line_re . match ( first ) options = '' if match : options = ( match . group ( 1 ) or '' ) if options : options = ( ' ' + options ) if wininst : executable = 'python.exe' else : executable = nt_quote_arg ( executable ) hdr = ( '#!%(executable)s%(options)s\n' % locals ( ) ) if ( unicode ( hdr , 'ascii' , 'ignore' ) . encode ( 'ascii' ) != hdr ) : if options : if options . strip ( ) . startswith ( '-' ) : options = ( ' -x' + options . strip ( ) [ 1 : ] ) else : options = ' -x' executable = fix_jython_executable ( executable , options ) hdr = ( '#!%(executable)s%(options)s\n' % locals ( ) ) return hdr
create a #! line .