comparison mercurial/packagescan.py @ 2509:6350b01d173f

merge with wsgi changes.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Tue, 27 Jun 2006 00:10:41 -0700
parents 976b6b2a1613
children c4325f0a9b91
comparison
equal deleted inserted replaced
2508:ab460a3f0e3a 2509:6350b01d173f
58 for f in fromlist: 58 for f in fromlist:
59 scope[f] = getattr(mod,f) 59 scope[f] = getattr(mod,f)
60 if type(scope[f]) == types.ModuleType: 60 if type(scope[f]) == types.ModuleType:
61 requiredmodules[scope[f].__name__] = 1 61 requiredmodules[scope[f].__name__] = 1
62 62
63 class SkipPackage(Exception):
64 def __init__(self, reason):
65 self.reason = reason
66
67 scan_in_progress = False
68
63 def scan(libpath,packagename): 69 def scan(libpath,packagename):
64 """ helper for finding all required modules of package <packagename> """ 70 """ helper for finding all required modules of package <packagename> """
71 global scan_in_progress
72 scan_in_progress = True
65 # Use the package in the build directory 73 # Use the package in the build directory
66 libpath = os.path.abspath(libpath) 74 libpath = os.path.abspath(libpath)
67 sys.path.insert(0,libpath) 75 sys.path.insert(0,libpath)
68 packdir = os.path.join(libpath,packagename.replace('.', '/')) 76 packdir = os.path.join(libpath,packagename.replace('.', '/'))
69 # A normal import would not find the package in 77 # A normal import would not find the package in
83 for m in pymodulefiles: 91 for m in pymodulefiles:
84 if m == '__init__.py': continue 92 if m == '__init__.py': continue
85 tmp = {} 93 tmp = {}
86 mname,ext = os.path.splitext(m) 94 mname,ext = os.path.splitext(m)
87 fullname = packagename+'.'+mname 95 fullname = packagename+'.'+mname
88 __import__(fullname,tmp,tmp) 96 try:
97 __import__(fullname,tmp,tmp)
98 except SkipPackage, inst:
99 print >> sys.stderr, 'skipping %s: %s' % (fullname, inst.reason)
100 continue
89 requiredmodules[fullname] = 1 101 requiredmodules[fullname] = 1
90 # Import all extension modules and by that run the fake demandload 102 # Import all extension modules and by that run the fake demandload
91 for m in extmodulefiles: 103 for m in extmodulefiles:
92 tmp = {} 104 tmp = {}
93 mname,ext = os.path.splitext(m) 105 mname,ext = os.path.splitext(m)