1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
Some modules such as dynamic library maybe cann't be imported while cross compile,
we just check whether does the module exist.
Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
--- ldb-1.1.17.orig/buildtools/wafsamba/samba_bundled.py 2015-07-16 16:42:12.265127110 +0800
+++ ldb-1.1.17/buildtools/wafsamba/samba_bundled.py 2015-07-16 16:45:25.717119550 +0800
@@ -1,7 +1,7 @@
# functions to support bundled libraries
from Configure import conf
-import sys, Logs
+import sys, Logs, imp
from samba_utils import *
def PRIVATE_NAME(bld, name, private_extension, private_library):
@@ -218,17 +218,32 @@ def CHECK_BUNDLED_SYSTEM_PYTHON(conf, li
# versions
minversion = minimum_library_version(conf, libname, minversion)
- try:
- m = __import__(modulename)
- except ImportError:
- found = False
- else:
+ # Find module in PYTHONPATH
+ stuff = imp.find_module(modulename, [os.environ["PYTHONPATH"]])
+ if stuff:
try:
- version = m.__version__
- except AttributeError:
+ m = imp.load_module(modulename, stuff[0], stuff[1], stuff[2])
+ except ImportError:
found = False
+
+ if conf.env.CROSS_COMPILE:
+ # Some modules such as dynamic library maybe cann't be imported
+ # while cross compile, we just check whether the module exist
+ Logs.warn('Cross module[%s] has been found, but can not be loaded.' % (stuff[1]))
+ found = True
else:
- found = tuplize_version(version) >= tuplize_version(minversion)
+ try:
+ version = m.__version__
+ except AttributeError:
+ found = False
+ else:
+ found = tuplize_version(version) >= tuplize_version(minversion)
+ finally:
+ if stuff[0]:
+ stuff[0].close()
+ else:
+ found = False
+
if not found and not conf.LIB_MAY_BE_BUNDLED(libname):
Logs.error('ERROR: Python module %s of version %s not found, and bundling disabled' % (libname, minversion))
sys.exit(1)
|