| Change setup.py to respect the SYSROOT environment variable. |
| This is needed to build the installed standard modules (e.g. readline & zlib). |
| |
| --- a/setup.py |
| +++ b/setup.py |
| @@ -57,6 +57,8 @@ MACOS = (HOST_PLATFORM == 'darwin') |
| AIX = (HOST_PLATFORM.startswith('aix')) |
| VXWORKS = ('vxworks' in HOST_PLATFORM) |
| |
| +# We must respect the user specified sysroot! |
| +GENTOO_SYSROOT = os.getenv('SYSROOT', '') |
| |
| SUMMARY = """ |
| Python is an interpreted, interactive, object-oriented programming |
| @@ -126,6 +128,9 @@ def sysroot_paths(make_vars, subdirs): |
| headers or libraries. |
| """ |
| |
| + if GENTOO_SYSROOT: |
| + return [GENTOO_SYSROOT] |
| + |
| dirs = [] |
| for var_name in make_vars: |
| var = sysconfig.get_config_var(var_name) |
| @@ -653,8 +658,8 @@ class PyBuildExt(build_ext): |
| # directories (i.e. '.' and 'Include') must be first. See issue |
| # 10520. |
| if not CROSS_COMPILING: |
| - add_dir_to_list(self.compiler.library_dirs, '/usr/local/@@GENTOO_LIBDIR@@') |
| - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| + add_dir_to_list(self.compiler.library_dirs, GENTOO_SYSROOT + '/usr/local/@@GENTOO_LIBDIR@@') |
| + add_dir_to_list(self.compiler.include_dirs, GENTOO_SYSROOT + '/usr/local/include') |
| # only change this for cross builds for 3.3, issues on Mageia |
| if CROSS_COMPILING: |
| self.add_cross_compiling_paths() |
| @@ -670,9 +675,9 @@ class PyBuildExt(build_ext): |
| # building a framework with different architectures than |
| # the one that is currently installed (issue #7473) |
| add_dir_to_list(self.compiler.library_dirs, |
| - sysconfig.get_config_var("LIBDIR")) |
| + GENTOO_SYSROOT + sysconfig.get_config_var("LIBDIR")) |
| add_dir_to_list(self.compiler.include_dirs, |
| - sysconfig.get_config_var("INCLUDEDIR")) |
| + GENTOO_SYSROOT + sysconfig.get_config_var("INCLUDEDIR")) |
| |
| system_lib_dirs = ['/@@GENTOO_LIBDIR@@', '/usr/@@GENTOO_LIBDIR@@'] |
| system_include_dirs = ['/usr/include'] |
| @@ -957,11 +962,11 @@ class PyBuildExt(build_ext): |
| elif curses_library: |
| readline_libs.append(curses_library) |
| elif self.compiler.find_library_file(self.lib_dirs + |
| - ['/usr/@@GENTOO_LIBDIR@@/termcap'], |
| + [GENTOO_SYSROOT + '/usr/@@GENTOO_LIBDIR@@/termcap'], |
| 'termcap'): |
| readline_libs.append('termcap') |
| self.add(Extension('readline', ['readline.c'], |
| - library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'], |
| + library_dirs=[GENTOO_SYSROOT + '/usr/@@GENTOO_LIBDIR@@/termcap'], |
| extra_link_args=readline_extra_link_args, |
| libraries=readline_libs)) |
| else: |
| @@ -975,7 +980,7 @@ class PyBuildExt(build_ext): |
| if curses_library == 'ncursesw': |
| curses_defines.append(('HAVE_NCURSESW', '1')) |
| if not CROSS_COMPILING: |
| - curses_includes.append('/usr/include/ncursesw') |
| + curses_includes.append(GENTOO_SYSROOT + '/usr/include/ncursesw') |
| # Bug 1464056: If _curses.so links with ncursesw, |
| # _curses_panel.so must link with panelw. |
| panel_library = 'panelw' |
| @@ -1127,6 +1132,7 @@ class PyBuildExt(build_ext): |
| db_inc_paths.append('/usr/local/include/db3%d' % x) |
| db_inc_paths.append('/pkg/db-3.%d/include' % x) |
| db_inc_paths.append('/opt/db-3.%d/include' % x) |
| + db_inc_paths = [GENTOO_SYSROOT + x for x in db_inc_paths] |
| |
| if CROSS_COMPILING: |
| db_inc_paths = [] |
| @@ -1373,7 +1379,7 @@ class PyBuildExt(build_ext): |
| sysroot = macosx_sdk_root() |
| |
| for d_ in self.inc_dirs + sqlite_inc_paths: |
| - d = d_ |
| + d = GENTOO_SYSROOT + d_ |
| if MACOS and is_macosx_sdk_path(d): |
| d = os.path.join(sysroot, d[1:]) |
| |
| @@ -1684,7 +1684,7 @@ |
| |
| def detect_uuid(self): |
| # Build the _uuid module if possible |
| - uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"]) |
| + uuid_incs = find_file("uuid.h", self.inc_dirs, [GENTOO_SYSROOT + "/usr/include/uuid"]) |
| if uuid_incs is not None: |
| if self.compiler.find_library_file(self.lib_dirs, 'uuid'): |
| uuid_libs = ['uuid'] |
| @@ -1803,7 +1809,7 @@ class PyBuildExt(build_ext): |
| # For 8.4a2, the X11 headers are not included. Rather than include a |
| # complicated search, this is a hard-coded path. It could bail out |
| # if X11 libs are not found... |
| - include_dirs.append('/usr/X11R6/include') |
| + include_dirs.append(GENTOO_SYSROOT + '/usr/X11R6/include') |
| frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] |
| |
| # All existing framework builds of Tcl/Tk don't support 64-bit |
| @@ -1917,8 +1923,8 @@ class PyBuildExt(build_ext): |
| added_lib_dirs.append('/usr/X11R5/@@GENTOO_LIBDIR@@') |
| else: |
| # Assume default location for X11 |
| - include_dirs.append('/usr/X11/include') |
| - added_lib_dirs.append('/usr/X11/@@GENTOO_LIBDIR@@') |
| + include_dirs.append(GENTOO_SYSROOT + '/usr/X11/include') |
| + added_lib_dirs.append(GENTOO_SYSROOT + '/usr/X11/@@GENTOO_LIBDIR@@') |
| |
| # If Cygwin, then verify that X is installed before proceeding |
| if CYGWIN: |