##// END OF EJS Templates
do not try to package lsprof if not available.
Vadim Gelfer -
r2497:976b6b2a default
parent child Browse files
Show More
@@ -4,7 +4,13 b''
4 # small modifications made
4 # small modifications made
5
5
6 import sys
6 import sys
7 from _lsprof import Profiler, profiler_entry, profiler_subentry
7 try:
8 from _lsprof import Profiler, profiler_entry, profiler_subentry
9 except ImportError, inst:
10 import packagescan
11 if packagescan.scan_in_progress:
12 raise packagescan.SkipPackage('_lsprof not available')
13 raise
8
14
9 __all__ = ['profile', 'Stats']
15 __all__ = ['profile', 'Stats']
10
16
@@ -60,8 +60,16 b' def demandload(scope, modules):'
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)
@@ -85,7 +93,11 b' def scan(libpath,packagename):'
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:
General Comments 0
You need to be logged in to leave comments. Login now