bpo-13501: allow choosing between readline and libedit (GH-24189)

In contrast to macOS, libedit is available as its own include file and
library on Linux systems to prevent file name clashes. So if both
libraries are available on the system, readline is currently chosen by
default; and if only libedit is available, it is not found at all. This
patch adds a way to link against libedit by adding the following
arguments to configure:

  --with-readline           link against libreadline (the default)
  --with-readline=editline  link against libeditline
  --with-readline=no        disable building the readline module
  --without-readline        (same)

The runtime detection of libedit vs. readline was already done in commit
7105319ada (2019-12-04, serge-sans-paille: "bpo-38634: Allow
non-apple build to cope with libedit (GH-16986)").

Fixes: GH-12076 ("bpo-13501 Build or disable readline with Editline")
Fixes: bpo-13501 ("Make libedit support more generic; port readline / libedit to FreeBSD")
Co-authored-by: Enji Cooper (ngie-eign)
Co-authored-by: Martin Panter (vadmium)
Co-authored-by: Robert Marshall (kellinm)
This commit is contained in:
Roland Hieber 2021-02-09 02:05:25 +01:00 committed by GitHub
parent bf2e7e55d7
commit e1f7769513
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 275 additions and 207 deletions

View file

@ -1022,7 +1022,6 @@ def detect_test_extensions(self):
def detect_readline_curses(self):
# readline
do_readline = self.compiler.find_library_file(self.lib_dirs, 'readline')
readline_termcap_library = ""
curses_library = ""
# Cannot use os.popen here in py3k.
@ -1030,7 +1029,13 @@ def detect_readline_curses(self):
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
# Determine if readline is already linked against curses or tinfo.
if do_readline:
if sysconfig.get_config_var('HAVE_LIBREADLINE'):
if sysconfig.get_config_var('WITH_EDITLINE'):
readline_lib = 'edit'
else:
readline_lib = 'readline'
do_readline = self.compiler.find_library_file(self.lib_dirs,
readline_lib)
if CROSS_COMPILING:
ret = run_command("%s -d %s | grep '(NEEDED)' > %s"
% (sysconfig.get_config_var('READELF'),
@ -1053,6 +1058,8 @@ def detect_readline_curses(self):
break
if os.path.exists(tmpfile):
os.unlink(tmpfile)
else:
do_readline = False
# 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:
@ -1092,7 +1099,7 @@ def detect_readline_curses(self):
else:
readline_extra_link_args = ()
readline_libs = ['readline']
readline_libs = [readline_lib]
if readline_termcap_library:
pass # Issue 7384: Already linked against curses or tinfo.
elif curses_library: