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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. @@ -360,10 +361,7 @@
  25. # directly since an inconsistently reproducible issue comes up where
  26. # the environment variable is not set even though the value were passed
  27. # into configure and stored in the Makefile (issue found on OS X 10.3).
  28. - for env_var, arg_name, dir_list in (
  29. - ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
  30. - ('LDFLAGS', '-L', self.compiler.library_dirs),
  31. - ('CPPFLAGS', '-I', self.compiler.include_dirs)):
  32. + for env_var, arg_name, dir_list in ():
  33. env_val = sysconfig.get_config_var(env_var)
  34. if env_val:
  35. # To prevent optparse from raising an exception about any
  36. @@ -388,17 +386,6 @@
  37. for directory in reversed(options.dirs):
  38. add_dir_to_list(dir_list, directory)
  39. - if os.path.normpath(sys.prefix) != '/usr' \
  40. - and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
  41. - # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
  42. - # (PYTHONFRAMEWORK is set) to avoid # linking problems when
  43. - # building a framework with different architectures than
  44. - # the one that is currently installed (issue #7473)
  45. - add_dir_to_list(self.compiler.library_dirs,
  46. - sysconfig.get_config_var("LIBDIR"))
  47. - add_dir_to_list(self.compiler.include_dirs,
  48. - sysconfig.get_config_var("INCLUDEDIR"))
  49. -
  50. try:
  51. have_unicode = unicode
  52. except NameError:
  53. @@ -407,11 +394,16 @@
  54. # lib_dirs and inc_dirs are used to search for files;
  55. # if a file is found in one of those directories, it can
  56. # be assumed that no additional -I,-L directives are needed.
  57. - lib_dirs = self.compiler.library_dirs + [
  58. - '/lib64', '/usr/lib64',
  59. - '/lib', '/usr/lib',
  60. - ]
  61. - inc_dirs = self.compiler.include_dirs + ['/usr/include']
  62. + lib_dirs = self.compiler.library_dirs
  63. + inc_dirs = self.compiler.include_dirs
  64. +
  65. + if os.environ.get('CROSS_COMPILING') != 'yes':
  66. + lib_dirs += [
  67. + '/lib64', '/usr/lib64',
  68. + '/lib', '/usr/lib',
  69. + ]
  70. + inc_dirs += ['/usr/include']
  71. +
  72. exts = []
  73. missing = []
  74. @@ -844,6 +836,9 @@
  75. db_inc_paths.append('/pkg/db-3.%d/include' % x)
  76. db_inc_paths.append('/opt/db-3.%d/include' % x)
  77. + if os.environ.get('CROSS_COMPILING') == 'yes':
  78. + db_inc_paths = []
  79. +
  80. # Add some common subdirectories for Sleepycat DB to the list,
  81. # based on the standard include directories. This way DB3/4 gets
  82. # picked up when it is installed in a non-standard prefix and
  83. @@ -996,6 +991,9 @@
  84. MIN_SQLITE_VERSION = ".".join([str(x)
  85. for x in MIN_SQLITE_VERSION_NUMBER])
  86. + if os.environ.get('CROSS_COMPILING') == 'yes':
  87. + sqlite_inc_paths = []
  88. +
  89. # Scan the default include directories before the SQLite specific
  90. # ones. This allows one to override the copy of sqlite on OSX,
  91. # where /usr/include contains an old version of sqlite.
  92. @@ -1095,6 +1093,8 @@
  93. # the more recent berkeleydb's db.h file first in the include path
  94. # when attempting to compile and it will fail.
  95. f = "/usr/include/db.h"
  96. + if os.environ.get('CROSS_COMPILING') == 'yes':
  97. + f = ''
  98. if sys.platform == 'darwin':
  99. if is_macosx_sdk_path(f):