def find_needed_modules(mf=None, scripts=(), includes=(), packages=(), warn=warnings.warn): if mf is None: mf = modulegraph.ModuleGraph() # feed Modulefinder with everything, and return it. for path in scripts: mf.run_script(path) for mod in includes: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ['*']) else: mf.import_hook(mod) for f in packages: # If modulegraph has seen a reference to the package, then # we prefer to believe that (imp_find_module doesn't seem to locate # sub-packages) m = mf.findNode(f) if m is not None: path = m.packagepath[0] else: # Find path of package # TODO: use imp_find_module_or_importer try: path = imp_find_module(f)[1] except ImportError: warn("No package named %s" % f) continue # walk the path to find subdirs containing __init__.py files # scan the results (directory of __init__.py files) # first trim the path (of the head package), # then convert directory name in package name, # finally push into modulegraph. for (dirpath, dirnames, filenames) in os.walk(path): if '__init__.py' in filenames and dirpath.startswith(path): package = f + '.' + path[len(path) + 1:].replace(os.sep, '.') mf.import_hook(package, None, ["*"]) return mf
def find_needed_modules(mf=None, scripts=(), includes=(), packages=(), warn=warnings.warn): if mf is None: mf = modulegraph.ModuleGraph() # feed Modulefinder with everything, and return it. for path in scripts: mf.run_script(path) for mod in includes: if mod[-2:] == ".*": mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) for f in packages: # If modulegraph has seen a reference to the package, then # we prefer to believe that (imp_find_module doesn't seem to locate # sub-packages) m = mf.findNode(f) if m is not None: path = m.packagepath[0] else: # Find path of package # TODO: use imp_find_module_or_importer try: path = imp_find_module(f)[1] except ImportError: warn("No package named %s" % f) continue # walk the path to find subdirs containing __init__.py files # scan the results (directory of __init__.py files) # first trim the path (of the head package), # then convert directory name in package name, # finally push into modulegraph. for (dirpath, dirnames, filenames) in os.walk(path): if "__init__.py" in filenames and dirpath.startswith(path): package = f + "." + path[len(path) + 1 :].replace(os.sep, ".") mf.import_hook(package, None, ["*"]) return mf
def plat_prepare(includes, packages, excludes): # used by Python itself includes.update(["warnings", "unicodedata", "weakref"]) if not sys.platform.startswith("irix"): excludes.update(["AL", "sgi"]) if not sys.platform in ("mac", "darwin"): # XXX - this doesn't look nearly complete excludes.update( [ "Audio_mac", "Carbon.File", "Carbon.Folder", "Carbon.Folders", "EasyDialogs", "MacOS", "macfs", "macostools", "macpath", ] ) if not sys.platform == "win32": # only win32 excludes.update( [ "ntpath", "nturl2path", "win32api", "win32con", "win32event", "win32evtlogutil", "win32evtlog", "win32file", "win32gui", "win32pipe", "win32process", "win32security", "pywintypes", "winsound", "win32", "_winreg", ] ) if not sys.platform == "riscos": excludes.update(["riscosenviron", "riscospath", "rourl2path"]) if not sys.platform == "dos" or sys.platform.startswith("ms-dos"): excludes.update(["dos"]) if not sys.platform == "os2emx": excludes.update(["os2emxpath"]) excludes.update(set(["posix", "nt", "os2", "mac", "ce", "riscos"]) - set(sys.builtin_module_names)) try: imp_find_module("poll") except ImportError: excludes.update(["poll"])
def plat_prepare(includes, packages, excludes): # used by Python itself includes.update(["warnings", "unicodedata", "weakref"]) if not sys.platform.startswith('irix'): excludes.update([ 'AL', 'sgi', ]) if not sys.platform in ('mac', 'darwin'): # XXX - this doesn't look nearly complete excludes.update([ 'Audio_mac', 'Carbon.File', 'Carbon.Folder', 'Carbon.Folders', 'EasyDialogs', 'MacOS', 'macfs', 'macostools', 'macpath', ]) if not sys.platform == 'mac': excludes.update([ 'mkcwproject', ]) if not sys.platform == 'win32': # only win32 excludes.update([ 'ntpath', 'nturl2path', 'win32api', 'win32con', 'win32event', 'win32evtlogutil', 'win32evtlog', 'win32file', 'win32gui', 'win32pipe', 'win32process', 'win32security', 'pywintypes', 'winsound', 'win32', '_winreg', ]) if not sys.platform == 'riscos': excludes.update([ 'riscosenviron', 'riscospath', 'rourl2path', ]) if not sys.platform == 'dos' or sys.platform.startswith('ms-dos'): excludes.update([ 'dos', ]) if not sys.platform == 'os2emx': excludes.update([ 'os2emxpath' ]) excludes.update(set(['posix', 'nt', 'os2', 'mac', 'ce', 'riscos']) - set(sys.builtin_module_names)) try: imp_find_module('poll') except ImportError: excludes.update([ 'poll', ])
def plat_prepare(includes, packages, excludes): # used by Python itself includes.update(["warnings", "unicodedata", "weakref"]) if not sys.platform.startswith('irix'): excludes.update([ 'AL', 'sgi', ]) if not sys.platform in ('mac', 'darwin'): # XXX - this doesn't look nearly complete excludes.update([ 'Audio_mac', 'Carbon.File', 'Carbon.Folder', 'Carbon.Folders', 'EasyDialogs', 'MacOS', 'macfs', 'macostools', 'macpath', ]) if not sys.platform == 'mac': excludes.update([ 'mkcwproject', ]) if not sys.platform == 'win32': # only win32 excludes.update([ 'ntpath', 'nturl2path', 'win32api', 'win32con', 'win32event', 'win32evtlogutil', 'win32evtlog', 'win32file', 'win32gui', 'win32pipe', 'win32process', 'win32security', 'pywintypes', 'winsound', 'win32', '_winreg', ]) if not sys.platform == 'riscos': excludes.update([ 'riscosenviron', 'riscospath', 'rourl2path', ]) if not sys.platform == 'dos' or sys.platform.startswith('ms-dos'): excludes.update([ 'dos', ]) if not sys.platform == 'os2emx': excludes.update(['os2emxpath']) excludes.update( set(['posix', 'nt', 'os2', 'mac', 'ce', 'riscos']) - set(sys.builtin_module_names)) try: imp_find_module('poll') except ImportError: excludes.update([ 'poll', ])