Index: setup.py =================================================================== --- setup.py (revision 42536) +++ setup.py (working copy) @@ -448,22 +448,41 @@ # readline if self.compiler.find_library_file(lib_dirs, 'readline'): - readline_libs = ['readline'] - if self.compiler.find_library_file(lib_dirs, - 'ncursesw'): - readline_libs.append('ncursesw') - elif self.compiler.find_library_file(lib_dirs, - 'ncurses'): - readline_libs.append('ncurses') - elif self.compiler.find_library_file(lib_dirs, 'curses'): - readline_libs.append('curses') - elif self.compiler.find_library_file(lib_dirs + - ['/usr/lib/termcap'], - 'termcap'): - readline_libs.append('termcap') - exts.append( Extension('readline', ['readline.c'], - library_dirs=['/usr/lib/termcap'], - libraries=readline_libs) ) + # This extra compilation helps identify incomplete + # implementations like BSD's libedit masquerading as readline. + # Unfortunately, I don't think distutils has clean + # symbol-finding routines like configure. Maybe this will + # motivate someone to implement something or prove me wrong and + # correct this code... + hist_inc = find_file('history.h', [], inc_dirs) + have_hist = False + if hist_inc: + for hist_dir in hist_inc: + hist_file = os.path.join(hist_dir, 'history.h') + have_hist = ("history_truncate_file" in + open(hist_file).read()) + if have_hist: + break + if have_hist: + readline_libs = ['readline'] + if self.compiler.find_library_file(lib_dirs, + 'ncursesw'): + readline_libs.append('ncursesw') + elif self.compiler.find_library_file(lib_dirs, + 'ncurses'): + readline_libs.append('ncurses') + elif self.compiler.find_library_file(lib_dirs, 'curses'): + readline_libs.append('curses') + elif self.compiler.find_library_file(lib_dirs + + ['/usr/lib/termcap'], + 'termcap'): + readline_libs.append('termcap') + exts.append( Extension('readline', ['readline.c'], + library_dirs=['/usr/lib/termcap'], + libraries=readline_libs) ) + else: + print "*** incomplete readline detected ***" + if platform not in ['mac']: # crypt module.