diff options
author | Guido van Rossum <guido@python.org> | 1998-05-18 20:21:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-05-18 20:21:56 (GMT) |
commit | f1b5a0e3aada9eac4112ddd533ecdc06bf0bf924 (patch) | |
tree | d2ebe5adf72f4035dcba4a6159fb5988d6389260 /Tools/freeze/modulefinder.py | |
parent | 5109ffd607b58237a35fcb364a9c6698ab511cde (diff) | |
download | cpython-f1b5a0e3aada9eac4112ddd533ecdc06bf0bf924.zip cpython-f1b5a0e3aada9eac4112ddd533ecdc06bf0bf924.tar.gz cpython-f1b5a0e3aada9eac4112ddd533ecdc06bf0bf924.tar.bz2 |
Add a feature to support specifying an additional search directory for
packages. (Mark Hammond)
Remove Emacs cruft.
Diffstat (limited to 'Tools/freeze/modulefinder.py')
-rw-r--r-- | Tools/freeze/modulefinder.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Tools/freeze/modulefinder.py b/Tools/freeze/modulefinder.py index 408c2ba..4c54ebd 100644 --- a/Tools/freeze/modulefinder.py +++ b/Tools/freeze/modulefinder.py @@ -22,6 +22,19 @@ if sys.platform=="win32": IMPORT_NAME = dis.opname.index('IMPORT_NAME') IMPORT_FROM = dis.opname.index('IMPORT_FROM') +# Modulefinder does a good job at simulating Python's, but it can not +# handle __path__ modifications packages make at runtime. Therefore there +# is a mechanism whereby you can register extra paths in this map for a +# package, and it will be honoured. + +# Note this is a mapping is lists of paths. +packagePathMap = {} + +# A Public interface +def AddPackagePath(packagename, path): + paths = packagePathMap.get(packagename, []) + paths.append(path) + packagePathMap[packagename] = paths class Module: @@ -288,6 +301,10 @@ class ModuleFinder: m = self.add_module(fqname) m.__file__ = pathname m.__path__ = [pathname] + + # As per comment at top of file, simulate runtime __path__ additions. + m.__path__ = m.__path__ + packagePathMap.get(fqname, []) + fp, buf, stuff = self.find_module("__init__", m.__path__) self.load_module(fqname, fp, buf, stuff) self.msgout(2, "load_package ->", m) @@ -405,7 +422,3 @@ if __name__ == '__main__': test() except KeyboardInterrupt: print "\n[interrupt]" - -# Local Variables: -# indent-tabs-mode: nil -# End: |