python-2.7-002-cross-compile.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Second patch to bring cross-compilation support to python build-system.
  2. Allow the libraries detection routine to look for headers and libs in
  3. other directories than /usr/include or /usr/lib through the env variables
  4. PYTHON_MODULES_INCLUDE and PYTHON_MODULES_LIB.
  5. We can then use it to look for libraries in the buildroot staging directory.
  6. Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>
  7. diff -rduNp Python-2.7.orig/setup.py Python-2.7/setup.py
  8. --- Python-2.7.orig/setup.py 2010-09-21 17:15:31.000000000 +0200
  9. +++ Python-2.7/setup.py 2010-09-21 17:20:46.000000000 +0200
  10. @@ -346,6 +346,18 @@ class PyBuildExt(build_ext):
  11. return sys.platform
  12. def detect_modules(self):
  13. + try:
  14. + modules_include_dirs = os.environ["PYTHON_MODULES_INCLUDE"].split()
  15. + except KeyError:
  16. + modules_include_dirs = ['/usr/include']
  17. + try:
  18. + modules_lib_dirs = os.environ["PYTHON_MODULES_LIB"].split()
  19. + except KeyError:
  20. + modules_include_dirs = ['/usr/lib']
  21. + for dir in modules_include_dirs:
  22. + add_dir_to_list(self.compiler.include_dirs, dir)
  23. + for dir in modules_lib_dirs:
  24. + add_dir_to_list(self.compiler.library_dirs, dir)
  25. # Add paths specified in the environment variables LDFLAGS and
  26. # CPPFLAGS for header and library files.
  27. # We must get the values from the Makefile and not the environment
  28. @@ -388,11 +400,8 @@ class PyBuildExt(build_ext):
  29. # lib_dirs and inc_dirs are used to search for files;
  30. # if a file is found in one of those directories, it can
  31. # be assumed that no additional -I,-L directives are needed.
  32. - lib_dirs = self.compiler.library_dirs + [
  33. - '/lib64', '/usr/lib64',
  34. - '/lib', '/usr/lib',
  35. - ]
  36. - inc_dirs = self.compiler.include_dirs + ['/usr/include']
  37. + lib_dirs = self.compiler.library_dirs
  38. + inc_dirs = self.compiler.include_dirs
  39. exts = []
  40. missing = []