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

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