#NEWLINE# def main( ) : #NEWLINE# #INDENT# ' Main program flow of Nuitka\n\n        At this point, options will be parsed already, Nuitka will be executing\n        in the desired version of Python with desired flags, and we just get\n        to execute the task assigned.\n\n        We might be asked to only re-compile generated C++, dump only an XML\n        representation of the internal node tree after optimization, etc.\n    ' #NEWLINE# positional_args = Options . getPositionalArgs ( ) #NEWLINE# assert ( len ( positional_args ) > 0 ) #NEWLINE# filename = Options . getPositionalArgs ( ) [ 0 ] #NEWLINE# Importing . setMainScriptDirectory ( main_dir = Utils . dirname ( Utils . abspath ( filename ) ) ) #NEWLINE# if Options . isStandaloneMode ( ) : #NEWLINE# #INDENT# for module in detectEarlyImports ( ) : #NEWLINE# #INDENT# ModuleRegistry . addUncompiledModule ( module ) #NEWLINE# if ( module . getName ( ) == 'site' ) : #NEWLINE# #INDENT# origin_prefix_filename = Utils . joinpath ( Utils . dirname ( module . getCompileTimeFilename ( ) ) , 'orig-prefix.txt' ) #NEWLINE# if Utils . isFile ( origin_prefix_filename ) : #NEWLINE# #INDENT# data_files . append ( ( filename , 'orig-prefix.txt' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# main_module = createNodeTree ( filename = filename ) #NEWLINE# #UNINDENT# except ( SyntaxError , IndentationError ) as e : #NEWLINE# #INDENT# sys . exit ( SyntaxErrors . formatOutput ( e ) ) #NEWLINE# #UNINDENT# if Options . shallDumpBuiltTreeXML ( ) : #NEWLINE# #INDENT# for module in ModuleRegistry . getDoneModules ( ) : #NEWLINE# #INDENT# dumpTreeXML ( module ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if Options . shallDisplayBuiltTree ( ) : #NEWLINE# #INDENT# displayTree ( main_module ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( result , options ) = compileTree ( main_module = main_module ) #NEWLINE# if ( not result ) : #NEWLINE# #INDENT# sys . exit ( 1 ) #NEWLINE# #UNINDENT# if Options . shallNotDoExecCppCall ( ) : #NEWLINE# #INDENT# sys . exit ( 0 ) #NEWLINE# #UNINDENT# if Options . isRemoveBuildDir ( ) : #NEWLINE# #INDENT# shutil . rmtree ( getSourceDirectoryPath ( main_module ) ) #NEWLINE# #UNINDENT# if Options . isStandaloneMode ( ) : #NEWLINE# #INDENT# binary_filename = ( options [ 'result_name' ] + '.exe' ) #NEWLINE# standalone_entry_points . insert ( 0 , ( binary_filename , None ) ) #NEWLINE# dist_dir = getStandaloneDirectoryPath ( main_module ) #NEWLINE# for module in ModuleRegistry . getDoneUserModules ( ) : #NEWLINE# #INDENT# standalone_entry_points . extend ( Plugins . considerExtraDlls ( dist_dir , module ) ) #NEWLINE# #UNINDENT# for module in ModuleRegistry . getUncompiledModules ( ) : #NEWLINE# #INDENT# standalone_entry_points . extend ( Plugins . considerExtraDlls ( dist_dir , module ) ) #NEWLINE# #UNINDENT# copyUsedDLLs ( dist_dir = dist_dir , standalone_entry_points = standalone_entry_points ) #NEWLINE# for module in ModuleRegistry . getDoneModules ( ) : #NEWLINE# #INDENT# data_files . extend ( Plugins . considerDataFiles ( module ) ) #NEWLINE# #UNINDENT# for ( source_filename , target_filename ) in data_files : #NEWLINE# #INDENT# target_filename = Utils . joinpath ( getStandaloneDirectoryPath ( main_module ) , target_filename ) #NEWLINE# Utils . makePath ( Utils . dirname ( target_filename ) ) #NEWLINE# shutil . copy2 ( source_filename , target_filename ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( Utils . getOS ( ) != 'Windows' ) and Options . shallMakeModule ( ) ) : #NEWLINE# #INDENT# subprocess . call ( ( 'chmod' , '-x' , getResultFullpath ( main_module ) ) ) #NEWLINE# #UNINDENT# if Options . shallExecuteImmediately ( ) : #NEWLINE# #INDENT# if Options . shallMakeModule ( ) : #NEWLINE# #INDENT# executeModule ( tree = main_module , clean_path = Options . shallClearPythonPathEnvironment ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# executeMain ( binary_filename = getResultFullpath ( main_module ) , clean_path = Options . shallClearPythonPathEnvironment ( ) )