Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 1 | Change setup.py to respect the SYSROOT environment variable |
| 2 | |
| 3 | --- a/setup.py |
| 4 | +++ b/setup.py |
| 5 | @@ -337,9 +337,13 @@ |
| 6 | |
| 7 | def detect_modules(self): |
| 8 | global disable_ssl |
| 9 | + |
| 10 | + # We must respect the user specified sysroot! |
| 11 | + sysroot = os.getenv('SYSROOT', '') |
| 12 | + |
| 13 | # Ensure that /usr/local is always used |
| 14 | - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
| 15 | - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| 16 | + add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/local/lib') |
| 17 | + add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/local/include') |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 18 | self.add_multiarch_paths() |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 19 | |
| 20 | # Add paths specified in the environment variables LDFLAGS and |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 21 | @@ -375,10 +379,16 @@ |
| 22 | # building a framework with different architectures than |
| 23 | # the one that is currently installed (issue #7473) |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 24 | add_dir_to_list(self.compiler.library_dirs, |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 25 | - sysconfig.get_config_var("LIBDIR")) |
| 26 | + sysroot + sysconfig.get_config_var("LIBDIR")) |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 27 | add_dir_to_list(self.compiler.include_dirs, |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 28 | - sysconfig.get_config_var("INCLUDEDIR")) |
| 29 | + sysroot + sysconfig.get_config_var("INCLUDEDIR")) |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 30 | |
| 31 | + # We should always look into sysroot/usr/include and consider |
| 32 | + # also the lib dirs there for searching for files |
| 33 | + add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/include') |
| 34 | + add_dir_to_list(self.compiler.library_dirs, sysroot + '/@@GENTOO_LIBDIR@@') |
| 35 | + add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/@@GENTOO_LIBDIR@@') |
| 36 | + |
| 37 | try: |
| 38 | have_unicode = unicode |
| 39 | except NameError: |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 40 | @@ -389,6 +399,9 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 41 | '/lib', '/usr/lib', |
| 42 | ] |
| 43 | inc_dirs = self.compiler.include_dirs + ['/usr/include'] |
| 44 | + # Ignore previous settings. |
| 45 | + lib_dirs = self.compiler.library_dirs |
| 46 | + inc_dirs = self.compiler.include_dirs |
| 47 | exts = [] |
| 48 | missing = [] |
| 49 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 50 | @@ -613,11 +626,11 @@ |
| 51 | elif curses_library: |
| 52 | readline_libs.append(curses_library) |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 53 | elif self.compiler.find_library_file(lib_dirs + |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 54 | - ['/usr/@@GENTOO_LIBDIR@@/termcap'], |
| 55 | + [sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'], |
| 56 | 'termcap'): |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 57 | readline_libs.append('termcap') |
| 58 | exts.append( Extension('readline', ['readline.c'], |
| 59 | - library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'], |
| 60 | + library_dirs=[sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'], |
| 61 | extra_link_args=readline_extra_link_args, |
| 62 | libraries=readline_libs) ) |
| 63 | else: |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 64 | @@ -642,20 +655,20 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 65 | depends = ['socketmodule.h']) ) |
| 66 | # Detect SSL support for the socket module (via _ssl) |
| 67 | search_for_ssl_incs_in = [ |
| 68 | - '/usr/local/ssl/include', |
| 69 | - '/usr/contrib/ssl/include/' |
| 70 | + sysroot + '/usr/local/ssl/include', |
| 71 | + sysroot + '/usr/contrib/ssl/include/' |
| 72 | ] |
| 73 | ssl_incs = find_file('openssl/ssl.h', inc_dirs, |
| 74 | search_for_ssl_incs_in |
| 75 | ) |
| 76 | if ssl_incs is not None and not disable_ssl: |
| 77 | krb5_h = find_file('krb5.h', inc_dirs, |
| 78 | - ['/usr/kerberos/include']) |
| 79 | + [sysroot + '/usr/kerberos/include']) |
| 80 | if krb5_h: |
| 81 | ssl_incs += krb5_h |
| 82 | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, |
| 83 | - ['/usr/local/ssl/lib', |
| 84 | - '/usr/contrib/ssl/lib/' |
| 85 | + [sysroot + '/usr/local/ssl/lib', |
| 86 | + sysroot + '/usr/contrib/ssl/lib/' |
| 87 | ] ) |
| 88 | |
| 89 | if (ssl_incs is not None and |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 90 | @@ -773,6 +786,7 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 91 | db_inc_paths.append('/usr/local/include/db3%d' % x) |
| 92 | db_inc_paths.append('/pkg/db-3.%d/include' % x) |
| 93 | db_inc_paths.append('/opt/db-3.%d/include' % x) |
| 94 | + db_inc_paths = [sysroot + x for x in db_inc_paths] |
| 95 | |
| 96 | # Add some common subdirectories for Sleepycat DB to the list, |
| 97 | # based on the standard include directories. This way DB3/4 gets |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 98 | @@ -921,5 +935,6 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 99 | '/usr/local/include/sqlite', |
| 100 | '/usr/local/include/sqlite3', |
| 101 | ] |
| 102 | + sqlite_inc_paths = [sysroot + x for x in sqlite_inc_paths] |
| 103 | MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) |
| 104 | MIN_SQLITE_VERSION = ".".join([str(x) |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 105 | @@ -1021,7 +1036,7 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 106 | # we do not build this one. Otherwise this build will pick up |
| 107 | # the more recent berkeleydb's db.h file first in the include path |
| 108 | # when attempting to compile and it will fail. |
| 109 | - f = "/usr/include/db.h" |
| 110 | + f = sysroot + "/usr/include/db.h" |
| 111 | |
| 112 | if sys.platform == 'darwin': |
| 113 | if is_macosx_sdk_path(f): |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 114 | @@ -1546,7 +1561,7 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 115 | # For 8.4a2, the X11 headers are not included. Rather than include a |
| 116 | # complicated search, this is a hard-coded path. It could bail out |
| 117 | # if X11 libs are not found... |
| 118 | - include_dirs.append('/usr/X11R6/include') |
| 119 | + include_dirs.append(sysroot + '/usr/X11R6/include') |
| 120 | frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] |
| 121 | |
| 122 | # All existing framework builds of Tcl/Tk don't support 64-bit |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 123 | @@ -1579,6 +1594,9 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 124 | def detect_tkinter(self, inc_dirs, lib_dirs): |
| 125 | # The _tkinter module. |
| 126 | |
| 127 | + # We must respect the user specified sysroot! |
| 128 | + sysroot = os.getenv('SYSROOT', '') |
| 129 | + |
| 130 | # Rather than complicate the code below, detecting and building |
| 131 | # AquaTk is a separate method. Only one Tkinter will be built on |
| 132 | # Darwin - either AquaTk, if it is found, or X11 based Tk. |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 133 | @@ -1633,17 +1651,17 @@ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 134 | if platform == 'sunos5': |
| 135 | include_dirs.append('/usr/openwin/include') |
| 136 | added_lib_dirs.append('/usr/openwin/lib') |
| 137 | - elif os.path.exists('/usr/X11R6/include'): |
| 138 | - include_dirs.append('/usr/X11R6/include') |
| 139 | - added_lib_dirs.append('/usr/X11R6/lib64') |
| 140 | - added_lib_dirs.append('/usr/X11R6/lib') |
| 141 | - elif os.path.exists('/usr/X11R5/include'): |
| 142 | - include_dirs.append('/usr/X11R5/include') |
| 143 | - added_lib_dirs.append('/usr/X11R5/lib') |
| 144 | + elif os.path.exists(sysroot + '/usr/X11R6/include'): |
| 145 | + include_dirs.append(sysroot + '/usr/X11R6/include') |
| 146 | + added_lib_dirs.append(sysroot + '/usr/X11R6/lib64') |
| 147 | + added_lib_dirs.append(sysroot + '/usr/X11R6/lib') |
| 148 | + elif os.path.exists(sysroot + '/usr/X11R5/include'): |
| 149 | + include_dirs.append(sysroot + '/usr/X11R5/include') |
| 150 | + added_lib_dirs.append(sysroot + '/usr/X11R5/lib') |
| 151 | else: |
| 152 | # Assume default location for X11 |
| 153 | - include_dirs.append('/usr/X11/include') |
| 154 | - added_lib_dirs.append('/usr/X11/lib') |
| 155 | + include_dirs.append(sysroot + '/usr/X11/include') |
| 156 | + added_lib_dirs.append(sysroot + '/usr/X11/lib') |
| 157 | |
| 158 | # If Cygwin, then verify that X is installed before proceeding |
| 159 | if platform == 'cygwin': |