python-2.7-004-no-host-headers-libs.patch 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Do not look at host headers/libraries in cross-compile mode
  2. When we are cross-compiling, setup.py should never look in /usr or
  3. /usr/local to find headers or libraries. A later patch adds a
  4. mechanism to tell setup.py to look in a specific directory for headers
  5. and libraries.
  6. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  7. ---
  8. setup.py | 39 +++++++++++++++++++++------------------
  9. 1 file changed, 21 insertions(+), 18 deletions(-)
  10. Index: Python-2.7.1/setup.py
  11. ===================================================================
  12. --- Python-2.7.1.orig/setup.py
  13. +++ Python-2.7.1/setup.py
  14. @@ -351,8 +351,9 @@
  15. def detect_modules(self):
  16. # Ensure that /usr/local is always used
  17. - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
  18. - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
  19. + if os.environ.get('CROSS_COMPILING') != 'yes':
  20. + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
  21. + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
  22. # Add paths specified in the environment variables LDFLAGS and
  23. # CPPFLAGS for header and library files.
  24. @@ -388,17 +389,6 @@
  25. for directory in reversed(options.dirs):
  26. add_dir_to_list(dir_list, directory)
  27. - if os.path.normpath(sys.prefix) != '/usr' \
  28. - and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
  29. - # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
  30. - # (PYTHONFRAMEWORK is set) to avoid # linking problems when
  31. - # building a framework with different architectures than
  32. - # the one that is currently installed (issue #7473)
  33. - add_dir_to_list(self.compiler.library_dirs,
  34. - sysconfig.get_config_var("LIBDIR"))
  35. - add_dir_to_list(self.compiler.include_dirs,
  36. - sysconfig.get_config_var("INCLUDEDIR"))
  37. -
  38. try:
  39. have_unicode = unicode
  40. except NameError:
  41. @@ -407,11 +397,16 @@
  42. # lib_dirs and inc_dirs are used to search for files;
  43. # if a file is found in one of those directories, it can
  44. # be assumed that no additional -I,-L directives are needed.
  45. - lib_dirs = self.compiler.library_dirs + [
  46. - '/lib64', '/usr/lib64',
  47. - '/lib', '/usr/lib',
  48. - ]
  49. - inc_dirs = self.compiler.include_dirs + ['/usr/include']
  50. + lib_dirs = self.compiler.library_dirs
  51. + inc_dirs = self.compiler.include_dirs
  52. +
  53. + if os.environ.get('CROSS_COMPILING') != 'yes':
  54. + lib_dirs += [
  55. + '/lib64', '/usr/lib64',
  56. + '/lib', '/usr/lib',
  57. + ]
  58. + inc_dirs += ['/usr/include']
  59. +
  60. exts = []
  61. missing = []
  62. @@ -844,6 +839,9 @@
  63. db_inc_paths.append('/pkg/db-3.%d/include' % x)
  64. db_inc_paths.append('/opt/db-3.%d/include' % x)
  65. + if os.environ.get('CROSS_COMPILING') == 'yes':
  66. + db_inc_paths = []
  67. +
  68. # Add some common subdirectories for Sleepycat DB to the list,
  69. # based on the standard include directories. This way DB3/4 gets
  70. # picked up when it is installed in a non-standard prefix and
  71. @@ -996,6 +994,9 @@
  72. MIN_SQLITE_VERSION = ".".join([str(x)
  73. for x in MIN_SQLITE_VERSION_NUMBER])
  74. + if os.environ.get('CROSS_COMPILING') == 'yes':
  75. + sqlite_inc_paths = []
  76. +
  77. # Scan the default include directories before the SQLite specific
  78. # ones. This allows one to override the copy of sqlite on OSX,
  79. # where /usr/include contains an old version of sqlite.
  80. @@ -1095,6 +1096,8 @@
  81. # the more recent berkeleydb's db.h file first in the include path
  82. # when attempting to compile and it will fail.
  83. f = "/usr/include/db.h"
  84. + if os.environ.get('CROSS_COMPILING') == 'yes':
  85. + f = ''
  86. if sys.platform == 'darwin':
  87. if is_macosx_sdk_path(f):