summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorStefan Krah <stefan@bytereef.org>2010-06-16 14:17:22 (GMT)
committerStefan Krah <stefan@bytereef.org>2010-06-16 14:17:22 (GMT)
commitea568854b079506c302725ac24529c60b61cc896 (patch)
tree0fa0a40cc94ce089160229e6109996dfc78f3353 /setup.py
parente8a3ce449714c535911ac6c1c589c72085d55414 (diff)
downloadcpython-ea568854b079506c302725ac24529c60b61cc896.zip
cpython-ea568854b079506c302725ac24529c60b61cc896.tar.gz
cpython-ea568854b079506c302725ac24529c60b61cc896.tar.bz2
Issue #7384: If the system readline library is linked against
ncurses, do not link the readline module against ncursesw.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py61
1 files changed, 42 insertions, 19 deletions
diff --git a/setup.py b/setup.py
index 6d28202..8aa4c09 100644
--- a/setup.py
+++ b/setup.py
@@ -15,6 +15,7 @@ from distutils.core import Extension, setup
from distutils.command.build_ext import build_ext
from distutils.command.install import install
from distutils.command.install_lib import install_lib
+from distutils.spawn import find_executable
# This global variable is used to hold the list of modules to be disabled.
disabled_module_list = []
@@ -601,6 +602,36 @@ class PyBuildExt(build_ext):
# readline
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+ readline_termcap_library = ""
+ curses_library = ""
+ # Determine if readline is already linked against curses or tinfo.
+ if do_readline and find_executable('ldd'):
+ fp = os.popen("ldd %s" % do_readline)
+ for ln in fp:
+ if 'curses' in ln:
+ readline_termcap_library = re.sub(
+ r'.*lib(n?cursesw?)\.so.*', r'\1', ln
+ ).rstrip()
+ break
+ if 'tinfo' in ln: # termcap interface split out from ncurses
+ readline_termcap_library = 'tinfo'
+ break
+ fp.close()
+ # Issue 7384: If readline is already linked against curses,
+ # use the same library for the readline and curses modules.
+ # Disabled since applications relying on ncursesw might break.
+ #
+ # if 'curses' in readline_termcap_library:
+ # curses_library = readline_termcap_library
+ # elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
+ # (...)
+ if self.compiler.find_library_file(lib_dirs, 'ncursesw'):
+ curses_library = 'ncursesw'
+ elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
+ curses_library = 'ncurses'
+ elif self.compiler.find_library_file(lib_dirs, 'curses'):
+ curses_library = 'curses'
+
if platform == 'darwin':
os_release = int(os.uname()[2].split('.')[0])
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
@@ -624,14 +655,10 @@ class PyBuildExt(build_ext):
readline_extra_link_args = ()
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')
+ if readline_termcap_library:
+ pass # Issue 7384: Already linked against curses or tinfo.
+ elif curses_library:
+ readline_libs.append(curses_library)
elif self.compiler.find_library_file(lib_dirs +
['/usr/lib/termcap'],
'termcap'):
@@ -1162,19 +1189,15 @@ class PyBuildExt(build_ext):
# Curses support, requiring the System V version of curses, often
# provided by the ncurses library.
panel_library = 'panel'
- if (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
- curses_libs = ['ncursesw']
- # Bug 1464056: If _curses.so links with ncursesw,
- # _curses_panel.so must link with panelw.
- panel_library = 'panelw'
- exts.append( Extension('_curses', ['_cursesmodule.c'],
- libraries = curses_libs) )
- elif (self.compiler.find_library_file(lib_dirs, 'ncurses')):
- curses_libs = ['ncurses']
+ if curses_library.startswith('ncurses'):
+ if curses_library == 'ncursesw':
+ # Bug 1464056: If _curses.so links with ncursesw,
+ # _curses_panel.so must link with panelw.
+ panel_library = 'panelw'
+ curses_libs = [curses_library]
exts.append( Extension('_curses', ['_cursesmodule.c'],
libraries = curses_libs) )
- elif (self.compiler.find_library_file(lib_dirs, 'curses')
- and platform != 'darwin'):
+ elif curses_library == 'curses' and platform != 'darwin':
# OSX has an old Berkeley curses, not good enough for
# the _curses module.
if (self.compiler.find_library_file(lib_dirs, 'terminfo')):