#NEWLINE# def makeSourceDirectory( main_module ) : #NEWLINE# #INDENT# ' Get the full list of modules imported, create code for all of them.\n\n    ' #NEWLINE# assert main_module . isCompiledPythonModule ( ) #NEWLINE# global_context = CodeGeneration . makeGlobalContext ( ) #NEWLINE# assert ( main_module in ModuleRegistry . getDoneModules ( ) ) #NEWLINE# for module in ModuleRegistry . getDoneUserModules ( ) : #NEWLINE# #INDENT# if module . isCompiledPythonModule ( ) : #NEWLINE# #INDENT# uncompiled_module = ModuleRegistry . getUncompiledModule ( module_name = module . getFullName ( ) , module_filename = module . getCompileTimeFilename ( ) ) #NEWLINE# if ( uncompiled_module is not None ) : #NEWLINE# #INDENT# if uncompiled_module . isUserProvided ( ) : #NEWLINE# #INDENT# ModuleRegistry . removeDoneModule ( module ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ModuleRegistry . removeUncompiledModule ( uncompiled_module ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for any_case_module in Options . getShallFollowModules ( ) : #NEWLINE# #INDENT# for module in ModuleRegistry . getDoneUserModules ( ) : #NEWLINE# #INDENT# if ( module . getFullName ( ) == any_case_module ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# warning ( ( "Didn't recurse to '%s', apparently not used." % any_case_module ) ) #NEWLINE# #UNINDENT# #UNINDENT# for module in ModuleRegistry . getDoneModules ( ) : #NEWLINE# #INDENT# if module . isCompiledPythonModule ( ) : #NEWLINE# #INDENT# Finalization . prepareCodeGeneration ( module ) #NEWLINE# #UNINDENT# #UNINDENT# source_dir = getSourceDirectoryPath ( main_module ) #NEWLINE# module_filenames = pickSourceFilenames ( source_dir = source_dir , modules = ModuleRegistry . getDoneModules ( ) ) #NEWLINE# prepared_modules = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for module in ModuleRegistry . getDoneModules ( ) : #NEWLINE# #INDENT# if module . isCompiledPythonModule ( ) : #NEWLINE# #INDENT# cpp_filename = module_filenames [ module ] #NEWLINE# prepared_modules [ cpp_filename ] = CodeGeneration . prepareModuleCode ( global_context = global_context , module = module , module_name = module . getFullName ( ) ) #NEWLINE# if ( ( module is main_module ) and ( not Options . shallMakeModule ( ) ) ) : #NEWLINE# #INDENT# prepared_modules [ cpp_filename ] [ 1 ] . getConstantCode ( 0 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for module in ModuleRegistry . getDoneModules ( ) : #NEWLINE# #INDENT# if module . isCompiledPythonModule ( ) : #NEWLINE# #INDENT# cpp_filename = module_filenames [ module ] #NEWLINE# ( template_values , module_context ) = prepared_modules [ cpp_filename ] #NEWLINE# source_code = CodeGeneration . generateModuleCode ( module_context = module_context , template_values = template_values ) #NEWLINE# writeSourceCode ( filename = cpp_filename , source_code = source_code ) #NEWLINE# if Options . isShowInclusion ( ) : #NEWLINE# #INDENT# info ( ( "Included compiled module '%s'." % module . getFullName ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if module . isPythonShlibModule ( ) : #NEWLINE# #INDENT# target_filename = Utils . joinpath ( getStandaloneDirectoryPath ( main_module ) , * module . getFullName ( ) . split ( '.' ) ) #NEWLINE# if ( Utils . getOS ( ) == 'Windows' ) : #NEWLINE# #INDENT# target_filename += '.pyd' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# target_filename += '.so' #NEWLINE# #UNINDENT# target_dir = Utils . dirname ( target_filename ) #NEWLINE# if ( not Utils . isDir ( target_dir ) ) : #NEWLINE# #INDENT# Utils . makePath ( source_code ) #NEWLINE# #UNINDENT# shutil . copy ( module . getFilename ( ) , target_filename ) #NEWLINE# standalone_entry_points . append ( ( target_filename , module . getPackage ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if module . isUncompiledPythonModule ( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , module #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# writeSourceCode ( filename = Utils . joinpath ( source_dir , '__constants.cpp' ) , source_code = ConstantCodes . getConstantsDefinitionCode ( context = global_context ) ) #NEWLINE# ( helper_decl_code , helper_impl_code ) = CodeGeneration . generateHelpersCode ( ModuleRegistry . getDoneUserModules ( ) ) #NEWLINE# writeSourceCode ( filename = Utils . joinpath ( source_dir , '__helpers.hpp' ) , source_code = helper_decl_code ) #NEWLINE# writeSourceCode ( filename = Utils . joinpath ( source_dir , '__helpers.cpp' ) , source_code = helper_impl_code )