Skip to content

Commit 33f84a4

Browse files
committed
linux: use libedit instead of libreadline
readline is GPL 3.0 licensed. libedit has a more permissive license. This commit teaches the Linux build to use libedit instead of libreadline. Due to the change, we get a warning at run-time about the inability to locate the termcap database. There is still more work to do here. But at least the GPL 3.0 issue is behind us.
1 parent 39f1982 commit 33f84a4

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ On macOS, we statically link a ``libedit`` we compile ourselves. We
223223
dynamically link against ``libncurses``, which is provided by the
224224
system, typically in ``/usr/lib``.
225225

226+
On Linux, we statically link a ``libedit`` we compile ourselves, which
227+
is compiled against a ``libncurses`` we build ourselves.
228+
226229
Distribution Format
227230
===================
228231

cpython-linux/build-cpython.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ mv Setup.local Python-${PYTHON_VERSION}/Modules/Setup.local
2828

2929
pushd Python-${PYTHON_VERSION}
3030

31+
# Python supports using libedit instead of readline. But Modules/readline.c
32+
# has all of this behind ``#ifdef __APPLE__`` instead of a more specific
33+
# feature flag. All occurrences of __APPLE__ in that file are related to
34+
# libedit. So we just replace the content. USE_LIBEDIT comes from our
35+
# static-modules file.
36+
# TODO make changes upstream to allow libedit to more easily be used
37+
sed -i s/__APPLE__/USE_LIBEDIT/g Modules/readline.c
38+
3139
# Most bits look at CFLAGS. But setup.py only looks at CPPFLAGS.
3240
# So we need to set both.
3341
CFLAGS="-fPIC -I/tools/deps/include -I/tools/deps/include/ncurses"

cpython-linux/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,11 @@ def build_cpython(client, image, platform):
551551
install_tools_archive(container, BUILD / ('bzip2-%s.tar' % platform))
552552
# TODO build against Berkeley DB to avoid GPLv3.
553553
install_tools_archive(container, BUILD / ('gdbm-%s.tar' % platform))
554+
# TODO support libedit/libreadline toggle
555+
install_tools_archive(container, BUILD / ('libedit-%s.tar' % platform))
554556
install_tools_archive(container, BUILD / ('libffi-%s.tar' % platform))
555557
install_tools_archive(container, BUILD / ('ncurses-%s.tar' % platform))
556558
install_tools_archive(container, BUILD / ('openssl-%s.tar' % platform))
557-
install_tools_archive(container, BUILD / ('readline-%s.tar' % platform))
558559
install_tools_archive(container, BUILD / ('sqlite-%s.tar' % platform))
559560
# tk requires a bunch of X11 stuff.
560561
#install_tools_archive(container, BUILD / ('tcltk-%s.tar' % platform))

cpython-linux/static-modules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ _uuid _uuidmodule.c -I/tools/deps/include/uuid -luuid
3131
_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
3232
ossaudiodev ossaudiodev.c
3333
pyexpat pyexpat.c expat/xmlparse.c expat/xmlrole.c expat/xmltok.c -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -IModules/expat
34-
readline readline.c -I/tools/deps/include -I/tools/deps/include/ncurses -L/tools/deps/lib -lreadline -lncurses
34+
readline readline.c -DUSE_LIBEDIT=1 -I/tools/deps/include -I/tools/deps/include/ncurses -L/tools/deps/lib -ledit -lncurses
3535
xxlimited xxlimited.c -DPy_LIMITED_API=0x03050000

0 commit comments

Comments
 (0)