python-2.7-011-no-rpath.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Remove runtime library paths
  2. For some extensions (bsddb, sqlite and dbm), Python setup.py script
  3. hardcode a runtime path (rpath) into the extension. However, this
  4. runtime path is incorrect (because it points to the location of the
  5. library directory on the development machine) and useless (because on
  6. the target, all useful libraries are in a standard directory searched
  7. by the dynamic loader). For those reasons, we just get rid of the
  8. runtime paths in cross-compilation mode.
  9. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  10. ---
  11. setup.py | 21 ++++++++++++++++++---
  12. 1 file changed, 18 insertions(+), 3 deletions(-)
  13. Index: Python-2.7.2/setup.py
  14. ===================================================================
  15. --- Python-2.7.2.orig/setup.py
  16. +++ Python-2.7.2/setup.py
  17. @@ -997,6 +997,12 @@
  18. print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
  19. db_incs = [db_incdir]
  20. dblibs = [dblib]
  21. +
  22. + if os.environ.get('CROSS_COMPILING') == 'yes':
  23. + bsddb_runtime_library_dir = None
  24. + else:
  25. + bsddb_runtime_library_dir = dblib_dir
  26. +
  27. # We add the runtime_library_dirs argument because the
  28. # BerkeleyDB lib we're linking against often isn't in the
  29. # system dynamic library search path. This is usually
  30. @@ -1006,7 +1012,7 @@
  31. exts.append(Extension('_bsddb', ['_bsddb.c'],
  32. depends = ['bsddb.h'],
  33. library_dirs=dblib_dir,
  34. - runtime_library_dirs=dblib_dir,
  35. + runtime_library_dirs=bsddb_runtime_library_dir,
  36. include_dirs=db_incs,
  37. libraries=dblibs))
  38. else:
  39. @@ -1112,12 +1118,17 @@
  40. else:
  41. sqlite_extra_link_args = ()
  42. + if os.environ.get('CROSS_COMPILING') == 'yes':
  43. + sqlite_runtime_library_dirs = None
  44. + else:
  45. + sqlite_runtime_library_dirs = sqlite_libdir
  46. +
  47. exts.append(Extension('_sqlite3', sqlite_srcs,
  48. define_macros=sqlite_defines,
  49. include_dirs=["Modules/_sqlite",
  50. sqlite_incdir],
  51. library_dirs=sqlite_libdir,
  52. - runtime_library_dirs=sqlite_libdir,
  53. + runtime_library_dirs=sqlite_runtime_library_dirs,
  54. extra_link_args=sqlite_extra_link_args,
  55. libraries=["sqlite3",]))
  56. else:
  57. @@ -1218,9 +1229,13 @@
  58. elif cand == "bdb":
  59. if db_incs is not None:
  60. print "building dbm using bdb"
  61. + if os.environ.get('CROSS_COMPILING') == 'yes':
  62. + db_runtime_library_dir = None
  63. + else:
  64. + db_runtime_library_dir = dblib_dir
  65. dbmext = Extension('dbm', ['dbmmodule.c'],
  66. library_dirs=dblib_dir,
  67. - runtime_library_dirs=dblib_dir,
  68. + runtime_library_dirs=db_runtime_library_dir,
  69. include_dirs=db_incs,
  70. define_macros=[
  71. ('HAVE_BERKDB_H', None),