From 40ef17c7bc2345d58afaa9b6b731c53f91502156 Mon Sep 17 00:00:00 2001 From: Marin Jankovski <maxlazio@gmail.com> Date: Wed, 17 May 2017 21:00:35 +0200 Subject: [PATCH 1/4] Patch python to build with libedit. --- config/patches/python3/configure.ac.patch | 205 +++++++++++ config/patches/python3/configure.patch | 388 +++++++++++++++++++++ config/patches/python3/pyconfig.h.in.patch | 20 ++ config/patches/python3/readline.c.patch | 264 ++++++++++++++ config/patches/python3/setup.py.patch | 43 +++ config/software/python3.rb | 13 +- 6 files changed, 931 insertions(+), 2 deletions(-) create mode 100644 config/patches/python3/configure.ac.patch create mode 100644 config/patches/python3/configure.patch create mode 100644 config/patches/python3/pyconfig.h.in.patch create mode 100644 config/patches/python3/readline.c.patch create mode 100644 config/patches/python3/setup.py.patch diff --git a/config/patches/python3/configure.ac.patch b/config/patches/python3/configure.ac.patch new file mode 100644 index 0000000000..5b3424f4de --- /dev/null +++ b/config/patches/python3/configure.ac.patch @@ -0,0 +1,205 @@ +--- configure.ac.orig 2017-05-17 10:16:36.184012001 -0400 ++++ configure.ac 2017-05-17 12:13:10.127529009 -0400 +@@ -4155,87 +4155,129 @@ + [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) + fi + ++AC_ARG_WITH([readline], ++ [AS_HELP_STRING([--with(out)-readline@<:@=editline@:>@], ++ [use Editline for backend or disable readline module])], ++ [], ++ [with_readline=yes]) ++ + # check where readline lives ++py_cv_lib_readline=no + # save the value of LIBS so we don't actually link Python with readline + LIBS_no_readline=$LIBS + +-# On some systems we need to link readline to a termcap compatible +-# library. NOTE: Keep the precedence of listed libraries synchronised +-# with setup.py. +-py_cv_lib_readline=no +-AC_MSG_CHECKING([how to link readline libs]) +-for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do +- if test -z "$py_libtermcap"; then +- READLINE_LIBS="-lreadline" +- else +- READLINE_LIBS="-lreadline -l$py_libtermcap" ++if test "$with_readline" != no; then ++ case "$with_readline" in ++ editline|edit) ++ LIBREADLINE=edit ++ AC_DEFINE(WITH_EDITLINE, 1, ++ [Define to build the readline module against Editline.]) ++ ;; ++ yes|readline) ++ LIBREADLINE=readline ++ ;; ++ *) ++ AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline@:>@]) ++ ;; ++ esac ++ ++ # On some systems we need to link readline to a termcap compatible ++ # library. NOTE: Keep the precedence of listed libraries synchronised ++ # with setup.py. ++ AC_MSG_CHECKING([how to link readline libs]) ++ for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do ++ if test -z "$py_libtermcap"; then ++ READLINE_LIBS="-l$LIBREADLINE" ++ else ++ READLINE_LIBS="-l$LIBREADLINE -l$py_libtermcap" ++ fi ++ LIBS="$READLINE_LIBS $LIBS_no_readline" ++ AC_LINK_IFELSE( ++ [AC_LANG_CALL([],[readline])], ++ [py_cv_lib_readline=yes]) ++ if test $py_cv_lib_readline = yes; then ++ break ++ fi ++ done ++ ++ # Uncomment this line if you want to use READLINE_LIBS in Makefile or scripts ++ #AC_SUBST([READLINE_LIBS]) ++ if test $py_cv_lib_readline = no; then ++ AC_MSG_RESULT([none]) ++ else ++ AC_MSG_RESULT([$READLINE_LIBS]) ++ AC_DEFINE(HAVE_LIBREADLINE, 1, ++ [Define to build the readline module.]) + fi +- LIBS="$READLINE_LIBS $LIBS_no_readline" +- AC_LINK_IFELSE( +- [AC_LANG_CALL([],[readline])], +- [py_cv_lib_readline=yes]) +- if test $py_cv_lib_readline = yes; then +- break +- fi +-done +-# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts +-#AC_SUBST([READLINE_LIBS]) +-if test $py_cv_lib_readline = no; then +- AC_MSG_RESULT([none]) +-else +- AC_MSG_RESULT([$READLINE_LIBS]) +- AC_DEFINE(HAVE_LIBREADLINE, 1, +- [Define if you have the readline library (-lreadline).]) + fi + +-# check for readline 2.1 +-AC_CHECK_LIB(readline, rl_callback_handler_install, +- AC_DEFINE(HAVE_RL_CALLBACK, 1, +- [Define if you have readline 2.1]), ,$READLINE_LIBS) +- +-# check for readline 2.2 +-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], +- [have_readline=yes], +- [have_readline=no] +-) +-if test $have_readline = yes +-then +- AC_EGREP_HEADER([extern int rl_completion_append_character;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, +- [Define if you have readline 2.2]), ) +- AC_EGREP_HEADER([extern int rl_completion_suppress_append;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, +- [Define if you have rl_completion_suppress_append]), ) +-fi ++if test "$py_cv_lib_readline" = yes; then ++ # check for readline 2.1 ++ AC_CHECK_LIB($LIBREADLINE, rl_callback_handler_install, ++ AC_DEFINE(HAVE_RL_CALLBACK, 1, ++ [Define if you have readline 2.1]),,$READLINE_LIBS) ++ ++ # check for readline 2.2 ++ AC_CHECK_DECL(rl_completion_append_character, ++ AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, ++ [Define if you have readline 2.2]),, ++ [ ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif ++ ]) ++ AC_CHECK_DECL(rl_completion_suppress_append, ++ AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, ++ [Define if you have rl_completion_suppress_append]),, ++ [ ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif ++ ]) ++ ++ # check for readline 4.0 ++ AC_CHECK_LIB($LIBREADLINE, rl_pre_input_hook, ++ AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, ++ [Define if you have readline 4.0]),,$READLINE_LIBS) ++ ++ # also in 4.0 ++ AC_CHECK_LIB($LIBREADLINE, rl_completion_display_matches_hook, ++ AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, ++ [Define if you have readline 4.0]),,$READLINE_LIBS) ++ ++ # also in 4.0, but not in editline ++ AC_CHECK_LIB($LIBREADLINE, rl_resize_terminal, ++ AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1, ++ [Define if you have readline 4.0]),,$READLINE_LIBS) ++ ++ # check for readline 4.2 ++ AC_CHECK_LIB($LIBREADLINE, rl_completion_matches, ++ AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, ++ [Define if you have readline 4.2]),,$READLINE_LIBS) ++ ++ # also in readline 4.2 ++ AC_CHECK_DECL(rl_catch_signals, ++ AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, ++ [Define if you can turn off readline's signal handling.]),, ++ [ ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif ++ ]) ++ ++ AC_CHECK_LIB($LIBREADLINE, append_history, ++ AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1, ++ [Define if readline supports append_history]),,$READLINE_LIBS) + +-# check for readline 4.0 +-AC_CHECK_LIB(readline, rl_pre_input_hook, +- AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, +- [Define if you have readline 4.0]), ,$READLINE_LIBS) +- +-# also in 4.0 +-AC_CHECK_LIB(readline, rl_completion_display_matches_hook, +- AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, +- [Define if you have readline 4.0]), ,$READLINE_LIBS) +- +-# check for readline 4.2 +-AC_CHECK_LIB(readline, rl_completion_matches, +- AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, +- [Define if you have readline 4.2]), ,$READLINE_LIBS) +- +-# also in readline 4.2 +-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], +- [have_readline=yes], +- [have_readline=no] +-) +-if test $have_readline = yes +-then +- AC_EGREP_HEADER([extern int rl_catch_signals;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, +- [Define if you can turn off readline's signal handling.]), ) + fi + + # End of readline checks: restore LIBS diff --git a/config/patches/python3/configure.patch b/config/patches/python3/configure.patch new file mode 100644 index 0000000000..bf43318730 --- /dev/null +++ b/config/patches/python3/configure.patch @@ -0,0 +1,388 @@ +--- configure.orig 2017-05-17 12:48:31.903887000 -0400 ++++ configure 2017-05-17 14:15:14.245000207 -0400 +@@ -819,6 +819,7 @@ + with_libm + with_libc + enable_big_digits ++with_readline + with_computed_gotos + with_ensurepip + ' +@@ -1504,6 +1505,8 @@ + --with-fpectl enable SIGFPE catching + --with-libm=STRING math library + --with-libc=STRING C library ++ --with(out)-readline[=editline] ++ use Editline for backend or disable readline module + --with(out)-computed-gotos + Use computed gotos in evaluation loop (enabled by + default on supported compilers) +@@ -14114,24 +14117,48 @@ + + fi + ++# Check whether --with-readline was given. ++if test "${with_readline+set}" = set; then : ++ withval=$with_readline; ++else ++ with_readline=yes ++fi ++ ++ + # check where readline lives ++py_cv_lib_readline=no + # save the value of LIBS so we don't actually link Python with readline + LIBS_no_readline=$LIBS + +-# On some systems we need to link readline to a termcap compatible +-# library. NOTE: Keep the precedence of listed libraries synchronised +-# with setup.py. +-py_cv_lib_readline=no +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link readline libs" >&5 ++if test "$with_readline" != no; then ++ case "$with_readline" in ++ editline|edit) ++ LIBREADLINE=edit ++ ++$as_echo "#define WITH_EDITLINE 1" >>confdefs.h ++ ++ ;; ++ yes|readline) ++ LIBREADLINE=readline ++ ;; ++ *) ++ as_fn_error $? "proper usage is --with(out)-readline[=editline]" "$LINENO" 5 ++ ;; ++ esac ++ ++ # On some systems we need to link readline to a termcap compatible ++ # library. NOTE: Keep the precedence of listed libraries synchronised ++ # with setup.py. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link readline libs" >&5 + $as_echo_n "checking how to link readline libs... " >&6; } +-for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do +- if test -z "$py_libtermcap"; then +- READLINE_LIBS="-lreadline" +- else +- READLINE_LIBS="-lreadline -l$py_libtermcap" +- fi +- LIBS="$READLINE_LIBS $LIBS_no_readline" +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++ for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do ++ if test -z "$py_libtermcap"; then ++ READLINE_LIBS="-l$LIBREADLINE" ++ else ++ READLINE_LIBS="-l$LIBREADLINE -l$py_libtermcap" ++ fi ++ LIBS="$READLINE_LIBS $LIBS_no_readline" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + + /* Override any GCC internal prototype to avoid an error. +@@ -14154,31 +14181,35 @@ + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +- if test $py_cv_lib_readline = yes; then +- break +- fi +-done +-# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts +-#AC_SUBST([READLINE_LIBS]) +-if test $py_cv_lib_readline = no; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 ++ if test $py_cv_lib_readline = yes; then ++ break ++ fi ++ done ++ ++ # Uncomment this line if you want to use READLINE_LIBS in Makefile or scripts ++ #AC_SUBST([READLINE_LIBS]) ++ if test $py_cv_lib_readline = no; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&6 + $as_echo "none" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_LIBS" >&5 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_LIBS" >&6 + $as_echo "$READLINE_LIBS" >&6; } + + $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h + ++ fi + fi + +-# check for readline 2.1 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5 +-$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; } +-if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then : ++if test "$py_cv_lib_readline" = yes; then ++ # check for readline 2.1 ++ as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_callback_handler_install" | $as_tr_sh` ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -l$LIBREADLINE" >&5 ++$as_echo_n "checking for rl_callback_handler_install in -l$LIBREADLINE... " >&6; } ++if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lreadline $READLINE_LIBS $LIBS" ++LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -14198,73 +14229,63 @@ + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_readline_rl_callback_handler_install=yes ++ eval "$as_ac_Lib=yes" + else +- ac_cv_lib_readline_rl_callback_handler_install=no ++ eval "$as_ac_Lib=no" + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_callback_handler_install" >&5 +-$as_echo "$ac_cv_lib_readline_rl_callback_handler_install" >&6; } +-if test "x$ac_cv_lib_readline_rl_callback_handler_install" = xyes; then : +- ++eval ac_res=\$$as_ac_Lib ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + $as_echo "#define HAVE_RL_CALLBACK 1" >>confdefs.h + + fi + + +-# check for readline 2.2 +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include <readline/readline.h> +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- have_readline=yes +-else +- have_readline=no +- +-fi +-rm -f conftest.err conftest.i conftest.$ac_ext +-if test $have_readline = yes +-then +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include <readline/readline.h> +- +-_ACEOF +-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "extern int rl_completion_append_character;" >/dev/null 2>&1; then : ++ # check for readline 2.2 ++ ac_fn_c_check_decl "$LINENO" "rl_completion_append_character" "ac_cv_have_decl_rl_completion_append_character" " ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif + ++" ++if test "x$ac_cv_have_decl_rl_completion_append_character" = xyes; then : ++ + $as_echo "#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1" >>confdefs.h + + fi +-rm -f conftest* + +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include <readline/readline.h> ++ ac_fn_c_check_decl "$LINENO" "rl_completion_suppress_append" "ac_cv_have_decl_rl_completion_suppress_append" " ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif + +-_ACEOF +-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then : ++" ++if test "x$ac_cv_have_decl_rl_completion_suppress_append" = xyes; then : + + $as_echo "#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1" >>confdefs.h + + fi +-rm -f conftest* + +-fi +- +-# check for readline 4.0 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5 +-$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; } +-if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then : ++ # check for readline 4.0 ++ as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_pre_input_hook" | $as_tr_sh` ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -l$LIBREADLINE" >&5 ++$as_echo_n "checking for rl_pre_input_hook in -l$LIBREADLINE... " >&6; } ++if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lreadline $READLINE_LIBS $LIBS" ++LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -14284,31 +14305,32 @@ + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_readline_rl_pre_input_hook=yes ++ eval "$as_ac_Lib=yes" + else +- ac_cv_lib_readline_rl_pre_input_hook=no ++ eval "$as_ac_Lib=no" + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_pre_input_hook" >&5 +-$as_echo "$ac_cv_lib_readline_rl_pre_input_hook" >&6; } +-if test "x$ac_cv_lib_readline_rl_pre_input_hook" = xyes; then : +- ++eval ac_res=\$$as_ac_Lib ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : ++ + $as_echo "#define HAVE_RL_PRE_INPUT_HOOK 1" >>confdefs.h + + fi + +- +-# also in 4.0 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5 +-$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; } +-if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then : ++ # also in 4.0 ++ as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_completion_display_matches_hook" | $as_tr_sh` ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -l$LIBREADLINE" >&5 ++$as_echo_n "checking for rl_completion_display_matches_hook in -l$LIBREADLINE... " >&6; } ++if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lreadline $READLINE_LIBS $LIBS" ++LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -14328,31 +14350,32 @@ + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_readline_rl_completion_display_matches_hook=yes ++ eval "$as_ac_Lib=yes" + else +- ac_cv_lib_readline_rl_completion_display_matches_hook=no ++ eval "$as_ac_Lib=no" + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_display_matches_hook" >&5 +-$as_echo "$ac_cv_lib_readline_rl_completion_display_matches_hook" >&6; } +-if test "x$ac_cv_lib_readline_rl_completion_display_matches_hook" = xyes; then : ++eval ac_res=\$$as_ac_Lib ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + + $as_echo "#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1" >>confdefs.h + + fi + +- +-# check for readline 4.2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5 +-$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; } +-if ${ac_cv_lib_readline_rl_completion_matches+:} false; then : ++ # check for readline 4.2 ++ as_ac_Lib=`$as_echo "ac_cv_lib_$LIBREADLINE''_rl_completion_matches" | $as_tr_sh` ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -l$LIBREADLINE" >&5 ++$as_echo_n "checking for rl_completion_matches in -l$LIBREADLINE... " >&6; } ++if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lreadline $READLINE_LIBS $LIBS" ++LIBS="-l$LIBREADLINE $READLINE_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -14372,44 +14395,36 @@ + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_readline_rl_completion_matches=yes ++ eval "$as_ac_Lib=yes" + else +- ac_cv_lib_readline_rl_completion_matches=no ++ eval "$as_ac_Lib=no" + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_matches" >&5 +-$as_echo "$ac_cv_lib_readline_rl_completion_matches" >&6; } +-if test "x$ac_cv_lib_readline_rl_completion_matches" = xyes; then : + ++eval ac_res=\$$as_ac_Lib ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : ++ + $as_echo "#define HAVE_RL_COMPLETION_MATCHES 1" >>confdefs.h + + fi + + +-# also in readline 4.2 +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include <readline/readline.h> +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- have_readline=yes +-else +- have_readline=no +- +-fi +-rm -f conftest.err conftest.i conftest.$ac_ext +-if test $have_readline = yes +-then +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include <readline/readline.h> ++ # also in readline 4.2 ++ ac_fn_c_check_decl "$LINENO" "rl_catch_signals" "ac_cv_have_decl_rl_catch_signals" " ++#include <stdio.h> /* Must be first for Gnu Readline */ ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else ++# include <readline/readline.h> ++#endif + +-_ACEOF +-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "extern int rl_catch_signals;" >/dev/null 2>&1; then : ++" ++if test "x$ac_cv_have_decl_rl_catch_signals" = xyes; then : + + $as_echo "#define HAVE_RL_CATCH_SIGNAL 1" >>confdefs.h diff --git a/config/patches/python3/pyconfig.h.in.patch b/config/patches/python3/pyconfig.h.in.patch new file mode 100644 index 0000000000..51f0aac527 --- /dev/null +++ b/config/patches/python3/pyconfig.h.in.patch @@ -0,0 +1,20 @@ +--- pyconfig.h.in.orig 2016-06-25 17:52:32.000000000 -0400 ++++ pyconfig.h.in 2017-05-17 10:19:52.240012001 -0400 +@@ -495,7 +495,7 @@ + /* Define to 1 if you have the <libintl.h> header file. */ + #undef HAVE_LIBINTL_H + +-/* Define if you have the readline library (-lreadline). */ ++/* Define to build the readline module. */ + #undef HAVE_LIBREADLINE + + /* Define to 1 if you have the `resolv' library (-lresolv). */ +@@ -1339,6 +1339,9 @@ + Dyld is necessary to support frameworks. */ + #undef WITH_DYLD + ++/* Define to build the readline module against Editline. */ ++#undef WITH_EDITLINE ++ + /* Define to 1 if libintl is needed for locale functions. */ + #undef WITH_LIBINTL diff --git a/config/patches/python3/readline.c.patch b/config/patches/python3/readline.c.patch new file mode 100644 index 0000000000..8b75f797e4 --- /dev/null +++ b/config/patches/python3/readline.c.patch @@ -0,0 +1,264 @@ +--- readline.c.orig 2016-06-25 17:52:32.000000000 -0400 ++++ readline.c 2017-05-17 08:34:42.244842000 -0400 +@@ -27,45 +27,47 @@ + # define RESTORE_LOCALE(sl) + #endif + ++#ifdef WITH_EDITLINE ++# include <editline/readline.h> ++#else + /* GNU readline definitions */ +-#undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */ +-#include <readline/readline.h> +-#include <readline/history.h> ++# undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */ ++# include <readline/readline.h> ++# include <readline/history.h> ++#endif + ++/* Readline 4.2 deprecated completion_matches() in favour of ++rl_completion_matches() */ + #ifdef HAVE_RL_COMPLETION_MATCHES + #define completion_matches(x, y) \ + rl_completion_matches((x), ((rl_compentry_func_t *)(y))) +-#else +-#if defined(_RL_FUNCTION_TYPEDEF) +-extern char **completion_matches(char *, rl_compentry_func_t *); +-#else +- +-#if !defined(__APPLE__) +-extern char **completion_matches(char *, CPFunction *); +-#endif +-#endif + #endif + +-#ifdef __APPLE__ + /* + * It is possible to link the readline module to the readline + * emulation library of editline/libedit. + * + * On OSX this emulation library is not 100% API compatible +- * with the "real" readline and cannot be detected at compile-time, ++ * with the "real" readline and if WITH_EDITLINE ++ * was not specified, cannot be detected at compile-time, + * hence we use a runtime check to detect if we're using libedit +- * +- * Currently there is one known API incompatibility: ++ */ ++#if defined(__APPLE__) && !defined(WITH_EDITLINE) ++# define DETECT_EDITLINE ++static int using_libedit_emulation = 0; ++static const char libedit_version_tag[] = "EditLine wrapper"; ++#endif ++ ++#if defined(WITH_EDITLINE) || defined(__APPLE__) ++# define SUPPORT_EDITLINE ++/* One incompatibility of Editline: + * - 'get_history' has a 1-based index with GNU readline, and a 0-based + * index with older versions of libedit's emulation. + * - Note that replace_history and remove_history use a 0-based index + * with both implementations. + */ +-static int using_libedit_emulation = 0; +-static const char libedit_version_tag[] = "EditLine wrapper"; +- + static int libedit_history_start = 0; +-#endif /* __APPLE__ */ ++#endif + + #ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK + static void +@@ -598,25 +600,6 @@ + \n\ + Returns current completer function."); + +-/* Private function to get current length of history. XXX It may be +- * possible to replace this with a direct use of history_length instead, +- * but it's not clear whether BSD's libedit keeps history_length up to date. +- * See issue #8065.*/ +- +-static int +-_py_get_history_length(void) +-{ +- HISTORY_STATE *hist_st = history_get_history_state(); +- int length = hist_st->length; +- /* the history docs don't say so, but the address of hist_st changes each +- time history_get_history_state is called which makes me think it's +- freshly malloc'd memory... on the other hand, the address of the last +- line stays the same as long as history isn't extended, so it appears to +- be malloc'd but managed by the history package... */ +- free(hist_st); +- return length; +-} +- + /* Exported function to get any element of history */ + + static PyObject * +@@ -627,27 +610,19 @@ + + if (!PyArg_ParseTuple(args, "i:index", &idx)) + return NULL; +-#ifdef __APPLE__ +- if (using_libedit_emulation) { +- /* Older versions of libedit's readline emulation +- * use 0-based indexes, while readline and newer +- * versions of libedit use 1-based indexes. +- */ +- int length = _py_get_history_length(); +- +- idx = idx - 1 + libedit_history_start; +- +- /* +- * Apple's readline emulation crashes when +- * the index is out of range, therefore +- * test for that and fail gracefully. +- */ +- if (idx < (0 + libedit_history_start) +- || idx >= (length + libedit_history_start)) { +- Py_RETURN_NONE; +- } ++#ifdef SUPPORT_EDITLINE ++ idx = idx - 1 + libedit_history_start; ++ ++ /* ++ * Apple's readline emulation (and maybe other versions of ++ * Editline) crash when the index is out of range, therefore ++ * test for that and fail gracefully. ++ */ ++ if (idx < libedit_history_start ++ || idx >= (history_length + libedit_history_start)) { ++ Py_RETURN_NONE; + } +-#endif /* __APPLE__ */ ++#endif /* SUPPORT_EDITLINE */ + if ((hist_ent = history_get(idx))) + return PyUnicode_FromString(hist_ent->line); + else { +@@ -665,7 +640,7 @@ + static PyObject * + get_current_history_length(PyObject *self, PyObject *noarg) + { +- return PyLong_FromLong((long)_py_get_history_length()); ++ return PyLong_FromLong(history_length); + } + + PyDoc_STRVAR(doc_get_current_history_length, +@@ -978,14 +953,16 @@ + Py_FatalError("not enough memory to save locale"); + #endif + +-#ifdef __APPLE__ ++#ifdef SUPPORT_EDITLINE + /* the libedit readline emulation resets key bindings etc +- * when calling rl_initialize. So call it upfront ++ * when calling rl_initialize. So call it before making those settings. + */ ++# ifdef DETECT_EDITLINE + if (using_libedit_emulation) ++# endif + rl_initialize(); + +- /* Detect if libedit's readline emulation uses 0-based ++ /* Detect if the backend library uses 0-based + * indexing or 1-based indexing. + */ + add_history("1"); +@@ -995,7 +972,7 @@ + libedit_history_start = 1; + } + clear_history(); +-#endif /* __APPLE__ */ ++#endif /* SUPPORT_EDITLINE */ + + using_history(); + +@@ -1021,7 +998,7 @@ + mod_state->begidx = PyLong_FromLong(0L); + mod_state->endidx = PyLong_FromLong(0L); + +-#ifndef __APPLE__ ++#ifndef SUPPORT_EDITLINE + if (!isatty(STDOUT_FILENO)) { + /* Issue #19884: stdout is no a terminal. Disable meta modifier + keys to not write the ANSI sequence "\033[1034h" into stdout. On +@@ -1039,13 +1016,20 @@ + * + * XXX: A bug in the readline-2.2 library causes a memory leak + * inside this function. Nothing we can do about it. ++ * ++ * For Editline, just invoke the user configuration; initialization was ++ * already done above. + */ +-#ifdef __APPLE__ ++#ifdef DETECT_EDITLINE + if (using_libedit_emulation) + rl_read_init_file(NULL); + else +-#endif /* __APPLE__ */ + rl_initialize(); ++#elif defined(WITH_EDITLINE) ++ rl_read_init_file(NULL); ++#else ++ rl_initialize(); ++#endif + + RESTORE_LOCALE(saved_locale) + } +@@ -1208,15 +1192,12 @@ + n = strlen(p); + if (n > 0) { + const char *line; +- int length = _py_get_history_length(); +- if (length > 0) +-#ifdef __APPLE__ +- if (using_libedit_emulation) { +- /* handle older 0-based or newer 1-based indexing */ +- line = (const char *)history_get(length + libedit_history_start - 1)->line; +- } else +-#endif /* __APPLE__ */ +- line = (const char *)history_get(length)->line; ++ if (history_length > 0) ++#ifdef SUPPORT_EDITLINE ++ line = history_get(history_length + libedit_history_start - 1)->line; ++#else ++ line = history_get(history_length)->line; ++#endif + else + line = ""; + if (strcmp(p, line)) +@@ -1240,12 +1221,15 @@ + /* Initialize the module */ + + PyDoc_STRVAR(doc_module, ++#ifndef WITH_EDITLINE + "Importing this module enables command line editing using GNU readline."); +- +-#ifdef __APPLE__ ++#endif ++#ifdef DETECT_EDITLINE + PyDoc_STRVAR(doc_module_le, ++#endif ++#ifdef SUPPORT_EDITLINE + "Importing this module enables command line editing using libedit readline."); +-#endif /* __APPLE__ */ ++#endif + + static struct PyModuleDef readlinemodule = { + PyModuleDef_HEAD_INIT, +@@ -1266,15 +1250,14 @@ + PyObject *m; + readlinestate *mod_state; + +-#ifdef __APPLE__ ++#ifdef DETECT_EDITLINE + if (strncmp(rl_library_version, libedit_version_tag, strlen(libedit_version_tag)) == 0) { + using_libedit_emulation = 1; + } + + if (using_libedit_emulation) + readlinemodule.m_doc = doc_module_le; +- +-#endif /* __APPLE__ */ ++#endif /* DETECT_EDITLINE */ + + m = PyModule_Create(&readlinemodule); diff --git a/config/patches/python3/setup.py.patch b/config/patches/python3/setup.py.patch new file mode 100644 index 0000000000..9da26d6186 --- /dev/null +++ b/config/patches/python3/setup.py.patch @@ -0,0 +1,43 @@ +--- setup.py.orig 2016-06-25 17:52:32.000000000 -0400 ++++ setup.py 2017-05-17 10:20:29.552012001 -0400 +@@ -658,7 +658,6 @@ + exts.append( Extension('audioop', ['audioop.c']) ) + + # readline +- do_readline = self.compiler.find_library_file(lib_dirs, 'readline') + readline_termcap_library = "" + curses_library = "" + # Cannot use os.popen here in py3k. +@@ -666,7 +665,13 @@ + 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(lib_dirs, ++ readline_lib) + if cross_compiling: + ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \ + % (sysconfig.get_config_var('READELF'), +@@ -689,6 +694,8 @@ + 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: +@@ -724,7 +731,7 @@ + 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: diff --git a/config/software/python3.rb b/config/software/python3.rb index 58b14b4c89..0935635a3f 100644 --- a/config/software/python3.rb +++ b/config/software/python3.rb @@ -19,7 +19,7 @@ name 'python3' default_version '3.4.5' -dependency 'readline' +dependency 'libedit' dependency 'ncurses' dependency 'zlib' dependency 'openssl' @@ -33,7 +33,7 @@ source url: "http://python.org/ftp/python/#{version}/Python-#{version}.tgz", relative_path "Python-#{version}" -LIB_PATH = %W(#{install_dir}/embedded/lib #{install_dir}/embedded/lib64 #{install_dir}/embedded/libexec #{install_dir}/lib #{install_dir}/lib64 #{install_dir}/libexec).freeze +LIB_PATH = %W(#{install_dir}/embedded/lib #{install_dir}/embedded/lib64 #{install_dir}/lib #{install_dir}/lib64 #{install_dir}/libexec) env = { 'CFLAGS' => "-I#{install_dir}/embedded/include -O3 -g -pipe", @@ -41,9 +41,18 @@ env = { } build do + # Patches below are based on patches provided by martin.panter, 2016-06-02 06:31 + # in https://bugs.python.org/issue13501 + patch source: 'configure.ac.patch', target: "configure.ac" + patch source: 'configure.patch', target: "configure" + patch source: 'pyconfig.h.in.patch', target: "pyconfig.h.in" + patch source: 'readline.c.patch', target: "Modules/readline.c" + patch source: 'setup.py.patch', target: "setup.py" + command ['./configure', "--prefix=#{install_dir}/embedded", '--enable-shared', + '--with-readline=editline', '--with-dbmliborder='].join(' '), env: env make env: env make 'install', env: env -- GitLab From 3e359ea77a12e4c6d7e454a514004ea79d148f35 Mon Sep 17 00:00:00 2001 From: Marin Jankovski <maxlazio@gmail.com> Date: Wed, 17 May 2017 21:01:20 +0200 Subject: [PATCH 2/4] Remove readline from the package. --- .../readline/readline-6.2-curses-link.patch | 16 ------ config/software/readline.rb | 51 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 config/patches/readline/readline-6.2-curses-link.patch delete mode 100644 config/software/readline.rb diff --git a/config/patches/readline/readline-6.2-curses-link.patch b/config/patches/readline/readline-6.2-curses-link.patch deleted file mode 100644 index f440d5dd53..0000000000 --- a/config/patches/readline/readline-6.2-curses-link.patch +++ /dev/null @@ -1,16 +0,0 @@ -link readline directly to ncurses since it needs symbols from it - -upstream readline does this on purpose (no direct linking), but -it doesn't make much sense in a Linux world - ---- a/support/shobj-conf -+++ b/support/shobj-conf -@@ -42,7 +42,7 @@ - SHOBJ_LIBS= - - SHLIB_XLDFLAGS= --SHLIB_LIBS= -+SHLIB_LIBS='-lncurses -ltinfo' - - SHLIB_DOT='.' - SHLIB_LIBPREF='lib' diff --git a/config/software/readline.rb b/config/software/readline.rb deleted file mode 100644 index 1841455562..0000000000 --- a/config/software/readline.rb +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright:: Copyright (c) 2016 GitLab Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -name 'readline' -default_version '6.2' - -# http://buildroot-busybox.2317881.n4.nabble.com/PATCH-readline-link-directly-against-ncurses-td24410.html -# https://bugzilla.redhat.com/show_bug.cgi?id=499837 -# http://lists.osgeo.org/pipermail/grass-user/2003-September/010290.html -# http://trac.sagemath.org/attachment/ticket/14405/readline-tinfo.diff -dependency 'ncurses' - -license 'GPL-3.0' -license_file 'COPYING' - -source url: "ftp://ftp.gnu.org/gnu/readline/readline-#{version}.tar.gz", - md5: '67948acb2ca081f23359d0256e9a271c' - -relative_path "#{name}-#{version}" - -build do - env = { - 'CFLAGS' => "-I#{install_dir}/embedded/include", - 'LDFLAGS' => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib" - } - - configure_command = [ - './configure', - '--with-curses', - "--prefix=#{install_dir}/embedded" - ].join(' ') - - patch source: 'readline-6.2-curses-link.patch', plevel: 1 - command configure_command, env: env - make " -j #{workers}", env: env - make 'install', env: env -end -- GitLab From 87196ce7c255bd0b62bd9bdc2813883940c48c74 Mon Sep 17 00:00:00 2001 From: Marin Jankovski <maxlazio@gmail.com> Date: Thu, 18 May 2017 13:29:34 +0200 Subject: [PATCH 3/4] Fix rubocop offense with non-frozen constants. --- config/software/python3.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/software/python3.rb b/config/software/python3.rb index 0935635a3f..9c96180c97 100644 --- a/config/software/python3.rb +++ b/config/software/python3.rb @@ -33,7 +33,7 @@ source url: "http://python.org/ftp/python/#{version}/Python-#{version}.tgz", relative_path "Python-#{version}" -LIB_PATH = %W(#{install_dir}/embedded/lib #{install_dir}/embedded/lib64 #{install_dir}/lib #{install_dir}/lib64 #{install_dir}/libexec) +LIB_PATH = %W(#{install_dir}/embedded/lib #{install_dir}/embedded/lib64 #{install_dir}/lib #{install_dir}/lib64 #{install_dir}/libexec).freeze env = { 'CFLAGS' => "-I#{install_dir}/embedded/include -O3 -g -pipe", -- GitLab From ef508a5bbddf6c2bd75647740a99e24548ceed40 Mon Sep 17 00:00:00 2001 From: Marin Jankovski <maxlazio@gmail.com> Date: Thu, 18 May 2017 16:55:36 +0200 Subject: [PATCH 4/4] [CI skip] Add python with libedit to changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 476e9a902a..96b36f8937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ omnibus-gitlab repository. - Change service running detection 18b51873 - Rename trigger schedules to pipeline schedules - Compile new binaries for gitlab-shell +- Compile python with libedit 9.1.2 -- GitLab