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