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.

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