def create_exe(outpath, c_code=None):
 assert (not os.path.exists(outpath)), outpath
 if which('gcc'):
  if (c_code is None):
   c_code = textwrap.dedent('\n                #include <unistd.h>\n                int main() {\n                    pause();\n                    return 1;\n                }\n                ')
  with tempfile.NamedTemporaryFile(suffix='.c', delete=False, mode='wt') as f:
   f.write(c_code)
  try:
   subprocess.check_call(['gcc', f.name, '-o', outpath])
  finally:
   safe_rmpath(f.name)
 else:
  if (c_code is not None):
   raise ValueError("can't specify c_code arg as gcc is not installed")
  shutil.copyfile(sys.executable, outpath)
  if POSIX:
   st = os.stat(outpath)
   os.chmod(outpath, (st.st_mode | stat.S_IEXEC))

def create_exe ( outpath , c_code = None ) : assert ( not os . path . exists ( outpath ) ) , outpath if which ( 'gcc' ) : if ( c_code is None ) : c_code = textwrap . dedent ( '\n                #include <unistd.h>\n                int main() {\n                    pause();\n                    return 1;\n                }\n                ' ) with tempfile . NamedTemporaryFile ( suffix = '.c' , delete = False , mode = 'wt' ) as f : f . write ( c_code ) try : subprocess . check_call ( [ 'gcc' , f . name , '-o' , outpath ] ) finally : safe_rmpath ( f . name ) else : if ( c_code is not None ) : raise ValueError ( "can't specify c_code arg as gcc is not installed" ) shutil . copyfile ( sys . executable , outpath ) if POSIX : st = os . stat ( outpath ) os . chmod ( outpath , ( st . st_mode | stat . S_IEXEC ) )
creates an executable file in the given location .