blob: e7ce4b1104087fd1de71e40e7714ac56811eaa2a [file] [log] [blame]
Change setup.py to respect the SYSROOT environment variable
--- a/setup.py
+++ b/setup.py
@@ -337,9 +337,13 @@
def detect_modules(self):
global disable_ssl
+
+ # We must respect the user specified sysroot!
+ sysroot = os.getenv('SYSROOT', '')
+
# Ensure that /usr/local is always used
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/local/lib')
+ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/local/include')
self.add_multiarch_paths()
# Add paths specified in the environment variables LDFLAGS and
@@ -375,10 +379,16 @@
# 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"))
+ sysroot + sysconfig.get_config_var("LIBDIR"))
add_dir_to_list(self.compiler.include_dirs,
- sysconfig.get_config_var("INCLUDEDIR"))
+ sysroot + sysconfig.get_config_var("INCLUDEDIR"))
+ # We should always look into sysroot/usr/include and consider
+ # also the lib dirs there for searching for files
+ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/include')
+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/@@GENTOO_LIBDIR@@')
+ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/@@GENTOO_LIBDIR@@')
+
try:
have_unicode = unicode
except NameError:
@@ -389,6 +399,9 @@
'/lib', '/usr/lib',
]
inc_dirs = self.compiler.include_dirs + ['/usr/include']
+ # Ignore previous settings.
+ lib_dirs = self.compiler.library_dirs
+ inc_dirs = self.compiler.include_dirs
exts = []
missing = []
@@ -613,11 +626,11 @@
elif curses_library:
readline_libs.append(curses_library)
elif self.compiler.find_library_file(lib_dirs +
- ['/usr/@@GENTOO_LIBDIR@@/termcap'],
+ [sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
'termcap'):
readline_libs.append('termcap')
exts.append( Extension('readline', ['readline.c'],
- library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'],
+ library_dirs=[sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
extra_link_args=readline_extra_link_args,
libraries=readline_libs) )
else:
@@ -642,20 +655,20 @@
depends = ['socketmodule.h']) )
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
- '/usr/local/ssl/include',
- '/usr/contrib/ssl/include/'
+ sysroot + '/usr/local/ssl/include',
+ sysroot + '/usr/contrib/ssl/include/'
]
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
search_for_ssl_incs_in
)
if ssl_incs is not None and not disable_ssl:
krb5_h = find_file('krb5.h', inc_dirs,
- ['/usr/kerberos/include'])
+ [sysroot + '/usr/kerberos/include'])
if krb5_h:
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
- ['/usr/local/ssl/lib',
- '/usr/contrib/ssl/lib/'
+ [sysroot + '/usr/local/ssl/lib',
+ sysroot + '/usr/contrib/ssl/lib/'
] )
if (ssl_incs is not None and
@@ -773,6 +786,7 @@
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 = [sysroot + x for x in db_inc_paths]
# Add some common subdirectories for Sleepycat DB to the list,
# based on the standard include directories. This way DB3/4 gets
@@ -921,5 +935,6 @@
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
]
+ sqlite_inc_paths = [sysroot + x for x in sqlite_inc_paths]
MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
MIN_SQLITE_VERSION = ".".join([str(x)
@@ -1021,7 +1036,7 @@
# we do not build this one. Otherwise this build will pick up
# the more recent berkeleydb's db.h file first in the include path
# when attempting to compile and it will fail.
- f = "/usr/include/db.h"
+ f = sysroot + "/usr/include/db.h"
if sys.platform == 'darwin':
if is_macosx_sdk_path(f):
@@ -1546,7 +1561,7 @@
# 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(sysroot + '/usr/X11R6/include')
frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
# All existing framework builds of Tcl/Tk don't support 64-bit
@@ -1579,6 +1594,9 @@
def detect_tkinter(self, inc_dirs, lib_dirs):
# The _tkinter module.
+ # We must respect the user specified sysroot!
+ sysroot = os.getenv('SYSROOT', '')
+
# Rather than complicate the code below, detecting and building
# AquaTk is a separate method. Only one Tkinter will be built on
# Darwin - either AquaTk, if it is found, or X11 based Tk.
@@ -1633,17 +1651,17 @@
if platform == 'sunos5':
include_dirs.append('/usr/openwin/include')
added_lib_dirs.append('/usr/openwin/lib')
- elif os.path.exists('/usr/X11R6/include'):
- include_dirs.append('/usr/X11R6/include')
- added_lib_dirs.append('/usr/X11R6/lib64')
- added_lib_dirs.append('/usr/X11R6/lib')
- elif os.path.exists('/usr/X11R5/include'):
- include_dirs.append('/usr/X11R5/include')
- added_lib_dirs.append('/usr/X11R5/lib')
+ elif os.path.exists(sysroot + '/usr/X11R6/include'):
+ include_dirs.append(sysroot + '/usr/X11R6/include')
+ added_lib_dirs.append(sysroot + '/usr/X11R6/lib64')
+ added_lib_dirs.append(sysroot + '/usr/X11R6/lib')
+ elif os.path.exists(sysroot + '/usr/X11R5/include'):
+ include_dirs.append(sysroot + '/usr/X11R5/include')
+ added_lib_dirs.append(sysroot + '/usr/X11R5/lib')
else:
# Assume default location for X11
- include_dirs.append('/usr/X11/include')
- added_lib_dirs.append('/usr/X11/lib')
+ include_dirs.append(sysroot + '/usr/X11/include')
+ added_lib_dirs.append(sysroot + '/usr/X11/lib')
# If Cygwin, then verify that X is installed before proceeding
if platform == 'cygwin':