diff -r ab8d74456403 setup.py --- a/setup.py Sat Jan 29 10:40:29 2011 +0100 +++ b/setup.py Sat Jan 29 11:28:13 2011 +0100 @@ -370,6 +370,42 @@ return platform return sys.platform + _chainload = int() + def does_library_chainload_library(self, libpath, libre):#TODO Version sup. + """Checks wether the library 'libpath' (absolute) chainloads the + library which is denoted by the regular expression 'libre'; + e.g. r'n?cursesw?' can be used to search for sorts of Curses. + Returns None or a '(libre-Match, Matching-Line)' tuple, + so that the shown re may return '("cursesw", LINE)'. + Also returns 'None' if the check is impossible due to missing tools. + 'self.build_temp' is created as necessary.""" + if isinstance(self._chainload, int): + self._chainload = None + if self.get_platform() == 'darwin': + if find_executable('otool'): + self._chainload = ('otool -L', r').+?\.dylib.*') + elif find_executable('ldd'): + self._chainload = ('ldd', r')\.so.*') + if not self._chainload: + return None + + # Cannot use os.popen here in py3k. + tmpfile = os.path.join(self.build_temp, 'library_chainload_check') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + + ret = (self._chainload[0] + " %s > %s") % (libpath, tmpfile) + ret = os.system(ret) + if ret >> 8 == 0: + with open(tmpfile) as fp: + for ln in fp: + if re.search(libre, ln): + ret = (re.sub(r'.*lib(' + libre + self._chainload[1], + r'\1', ln).rstrip(), ln) + break + os.unlink(tmpfile) + return ret + def detect_modules(self): # Ensure that /usr/local is always used, but the local build # directories (i.e. '.' and 'Include') must be first. See issue @@ -562,25 +598,12 @@ readline_termcap_library = "" curses_library = "" # Determine if readline is already linked against curses or tinfo. - if do_readline and find_executable('ldd'): - # Cannot use os.popen here in py3k. - tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib') - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - ret = os.system("ldd %s > %s" % (do_readline, tmpfile)) - if ret >> 8 == 0: - with open(tmpfile) as fp: - for ln in fp: - if 'curses' in ln: - readline_termcap_library = re.sub( - r'.*lib(n?cursesw?)\.so.*', r'\1', ln - ).rstrip() - break - # termcap interface split out from ncurses - if 'tinfo' in ln: - readline_termcap_library = 'tinfo' - break - os.unlink(tmpfile) + ret = self.does_library_chainload_library(do_readline, r'n?cursesw?') + if ret: + readline_termcap_library = ret[0] + if 'tinfo' in ret[1]: + readline_termcap_library = 'tinfo' + # Issue 7384: If readline is already linked against curses, # use the same library for the readline and curses modules. if 'curses' in readline_termcap_library: @@ -593,9 +616,15 @@ curses_library = 'curses' if platform == 'darwin': + # sdaoden: I don't know what this is all about, i am using + # MacOS X since 10.6, but both, 10.5 and 10.6 SDKs work properly! + # I've *never* used GNU Autoconf! os_release = int(os.uname()[2].split('.')[0]) - dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') - if dep_target and dep_target.split('.') < ['10', '5']: + # SDAODEN HACK dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') + dep_target = '10.5' # SDAODEN HACK + if os_release >= 9: + pass + elif dep_target and dep_target.split('.') < ['10', '5']: os_release = 8 if os_release < 9: # MacOSX 10.4 has a broken readline. Don't try to build