def considerImplicitImports(self, signal_change): for module_name, module_package in self.getImplicitImports(): _module_package, _module_name, module_filename = \ Importing.findModule( source_ref = self.source_ref, module_name = module_name, parent_package = module_package, level = -1, warn = True ) if module_filename is None: sys.exit( "Error, implicit module '%s' expected by '%s' not found" % ( module_name, self.getFullName() ) ) elif Utils.isDir(module_filename): module_kind = "py" elif module_filename.endswith(".py"): module_kind = "py" elif module_filename.endswith(".so"): module_kind = "shlib" elif module_filename.endswith(".pyd"): module_kind = "shlib" else: assert False, module_filename from nuitka.tree import Recursion decision, reason = Recursion.decideRecursion( module_filename = module_filename, module_name = module_name, module_package = module_package, module_kind = module_kind ) assert decision or reason == "Module is frozen." if decision: module_relpath = Utils.relpath(module_filename) imported_module, added_flag = Recursion.recurseTo( module_package = module_package, module_filename = module_filename, module_relpath = module_relpath, module_kind = module_kind, reason = reason ) from nuitka.ModuleRegistry import addUsedModule addUsedModule(imported_module) if added_flag: signal_change( "new_code", imported_module.getSourceReference(), "Recursed to module." )
def attemptRecursion( self, module ): if not Options.shallMakeModule(): # Make sure the package is recursed to. module_package = module.getPackage() if module_package is not None: package_package, _package_module_name, package_filename = Importing.findModule( source_ref = module.getSourceReference(), module_name = module_package, parent_package = None, level = 1 ) imported_module, added_flag = Recursion.recurseTo( module_package = package_package, module_filename = package_filename, module_relpath = Utils.relpath( package_filename ) ) if added_flag: self.signalChange( "new_code", imported_module.getSourceReference(), "Recursed to module package." )
def _recurseTo(self, constraint_collection, module_package, module_filename, module_relpath): from nuitka.tree import Recursion imported_module, added_flag = Recursion.recurseTo( module_package=module_package, module_filename=module_filename, module_relpath=module_relpath) if added_flag: constraint_collection.signalChange( "new_code", imported_module.getSourceReference(), "Recursed to module.") return imported_module
def _recurseTo( self, constraint_collection, module_package, module_filename, module_relpath ): from nuitka.tree import Recursion imported_module, added_flag = Recursion.recurseTo( module_package = module_package, module_filename = module_filename, module_relpath = module_relpath ) if added_flag: constraint_collection.signalChange( "new_code", imported_module.getSourceReference(), "Recursed to module." ) return imported_module
def attemptRecursion(self): # Make sure the package is recursed to. from nuitka.tree import Recursion from nuitka import Importing # Return the list of newly added modules. result = [] if self.package_name is not None and self.package is None: package_package, _package_module_name, package_filename = \ Importing.findModule( source_ref = self.getSourceReference(), module_name = self.package_name, parent_package = None, level = 1, warn = Utils.python_version < 330 ) # TODO: Temporary, if we can't find the package for Python3.3 that # is semi-OK, maybe. if Utils.python_version >= 330 and not package_filename: return [] imported_module, is_added = Recursion.recurseTo( module_package=package_package, module_filename=package_filename, module_relpath=Utils.relpath(package_filename), module_kind="py", reason="Containing package of recursed module.", ) self.package = imported_module if is_added: result.append(imported_module) if self.package: from nuitka.ModuleRegistry import addUsedModule addUsedModule(self.package) # print "Recursed to package", self.package_name result.extend(self.package.attemptRecursion()) return result
def attemptRecursion(self): # Make sure the package is recursed to. from nuitka.tree import Recursion from nuitka import Importing # Return the list of newly added modules. result = [] if self.package_name is not None and self.package is None: package_package, _package_module_name, package_filename = \ Importing.findModule( source_ref = self.getSourceReference(), module_name = self.package_name, parent_package = None, level = 1, warn = Utils.python_version < 330 ) # TODO: Temporary, if we can't find the package for Python3.3 that # is semi-OK, maybe. if Utils.python_version >= 330 and not package_filename: return [] imported_module, is_added = Recursion.recurseTo( module_package = package_package, module_filename = package_filename, module_relpath = Utils.relpath(package_filename), module_kind = "py", reason = "Containing package of recursed module.", ) self.package = imported_module if is_added: result.append(imported_module) if self.package: from nuitka.ModuleRegistry import addUsedModule addUsedModule(self.package) # print "Recursed to package", self.package_name result.extend(self.package.attemptRecursion()) return result
def attemptRecursion(self, module): if not Options.shallMakeModule(): # Make sure the package is recursed to. module_package = module.getPackage() if module_package is not None: package_package, _package_module_name, package_filename = Importing.findModule( source_ref=module.getSourceReference(), module_name=module_package, parent_package=None, level=1) imported_module, added_flag = Recursion.recurseTo( module_package=package_package, module_filename=package_filename, module_relpath=Utils.relpath(package_filename)) if added_flag: self.signalChange("new_code", imported_module.getSourceReference(), "Recursed to module package.")
def _consider(self, constraint_collection, module_filename, module_package): assert module_package is None or \ (type(module_package) is str and module_package != "") module_filename = Utils.normpath(module_filename) if Utils.isDir(module_filename): module_name = Utils.basename(module_filename) module_kind = "py" elif module_filename.endswith(".py"): module_name = Utils.basename(module_filename)[:-3] module_kind = "py" elif module_filename.endswith(".so"): module_kind = "shlib" module_name = Utils.basename(module_filename)[:-3] elif module_filename.endswith(".pyd"): module_kind = "shlib" module_name = Utils.basename(module_filename)[:-4] else: module_kind = None module_name = None if module_kind is not None: from nuitka.tree import Recursion decision, reason = Recursion.decideRecursion( module_filename = module_filename, module_name = module_name, module_package = module_package, module_kind = module_kind ) if decision: module_relpath = Utils.relpath(module_filename) imported_module, added_flag = Recursion.recurseTo( module_package = module_package, module_filename = module_filename, module_relpath = module_relpath, module_kind = module_kind, reason = reason ) if added_flag: constraint_collection.signalChange( "new_code", imported_module.getSourceReference(), "Recursed to module." ) return imported_module elif decision is None and module_kind == "py": if module_package is None: module_fullpath = module_name else: module_fullpath = module_package + "." + module_name if module_filename not in self._warned_about and \ module_fullpath not in getModuleWhiteList(): self._warned_about.add(module_filename) warning( """\ Not recursing to '%(full_path)s' (%(filename)s), please specify \ --recurse-none (do not warn), \ --recurse-all (recurse to all), \ --recurse-not-to=%(full_path)s (ignore it), \ --recurse-to=%(full_path)s (recurse to it) to change.""" % { "full_path" : module_fullpath, "filename" : module_filename } )
def _consider(self, constraint_collection, module_filename, module_package): assert module_package is None or \ (type(module_package) is str and module_package != "") module_filename = Utils.normpath(module_filename) if Utils.isDir(module_filename): module_name = Utils.basename(module_filename) module_kind = "py" elif module_filename.endswith(".py"): module_name = Utils.basename(module_filename)[:-3] module_kind = "py" elif module_filename.endswith(".so"): module_kind = "shlib" module_name = Utils.basename(module_filename)[:-3] elif module_filename.endswith(".pyd"): module_kind = "shlib" module_name = Utils.basename(module_filename)[:-4] else: module_kind = None module_name = None if module_kind is not None: from nuitka.tree import Recursion decision, reason = Recursion.decideRecursion( module_filename=module_filename, module_name=module_name, module_package=module_package, module_kind=module_kind) if decision: module_relpath = Utils.relpath(module_filename) imported_module, added_flag = Recursion.recurseTo( module_package=module_package, module_filename=module_filename, module_relpath=module_relpath, module_kind=module_kind, reason=reason) if added_flag: constraint_collection.signalChange( "new_code", imported_module.getSourceReference(), "Recursed to module.") return imported_module elif decision is None and module_kind == "py": if module_package is None: module_fullpath = module_name else: module_fullpath = module_package + "." + module_name if module_filename not in self._warned_about: self._warned_about.add(module_filename) warning("""\ Not recursing to '%(full_path)s' (%(filename)s), please specify \ --recurse-none (do not warn), \ --recurse-all (recurse to all), \ --recurse-not-to=%(full_path)s (ignore it), \ --recurse-to=%(full_path)s (recurse to it) to change.""" % { "full_path": module_fullpath, "filename": module_filename })