You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.9 KiB

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