Skip to content

Commit d54beaf

Browse files
author
Rafael Martins
committed
Add no readline variants
1 parent c999484 commit d54beaf

File tree

6 files changed

+155
-14
lines changed

6 files changed

+155
-14
lines changed

abs.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# the conda-build parameters to use for disabling --skip-existing
2+
build_parameters:
3+
- "--suppress-variables"
4+
#- "--skip-existing"
5+
- "--error-overlinking"
6+
- "--error-overdepending"
7+
8+
aggregate_check: false
9+
10+
channels:
11+
- norl
12+
13+
upload_without_merge: true

recipe/build_base.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ _common_configure_args+=(--with-tcltk-includes="-I${PREFIX}/include")
254254
_common_configure_args+=("--with-tcltk-libs=-L${PREFIX}/lib -ltcl8.6 -ltk8.6")
255255
_common_configure_args+=(--with-platlibdir=lib)
256256

257+
if [[ "${READLINE_MODE}" = readline ]]; then
258+
_common_configure_args+=(--with-readline=readline)
259+
elif [[ "${READLINE_MODE}" = editline ]]; then
260+
_common_configure_args+=(--with-readline=editline)
261+
elif [[ "${READLINE_MODE}" = none ]]; then
262+
_common_configure_args+=(--without-readline)
263+
fi
264+
257265
# Add more optimization flags for the static Python interpreter:
258266
declare -a PROFILE_TASK=()
259267
if [[ ${_OPTIMIZED} == yes ]]; then
@@ -457,7 +465,7 @@ pushd "${PREFIX}"/lib/python${VER}
457465
# Remove osx sysroot as it depends on the build machine
458466
sed -i.bak "s@-isysroot @@g" sysconfigfile
459467
# make sure $CONDA_BUILD_SYSROOT is not empty ...
460-
if [[ ${HOST} =~ .*darwin.* ]] && [[ -n ${CONDA_BUILD_SYSROOT} ]]; then
468+
if [[ ${HOST} =~ .*darwin.* ]] && [[ -n ${CONDA_BUILD_SYSROOT} ]]; then
461469
sed -i.bak "s@$CONDA_BUILD_SYSROOT @@g" sysconfigfile
462470
fi
463471
# Remove unfilled config option

recipe/conda_build_config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ python:
33
python_impl:
44
- cpython
55
libffi: # [win]
6-
- 3.4 # [win]
6+
- 3.4 # [win]
77
numpy:
88
- 1.21
9+
readline_mode:
10+
- readline
11+
- editline
12+
- none
913
MACOSX_SDK_VERSION: # [osx and x86_64]
1014
- 10.14 # [osx and x86_64]
1115
CONDA_BUILD_SYSROOT: # [osx and x86_64]

recipe/meta.yaml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% set ver2 = '.'.join(version.split('.')[0:2]) %}
55
{% set ver2nd = ''.join(version.split('.')[0:2]) %}
66
{% set ver3nd = ''.join(version.split('.')[0:3]) %}
7-
{% set build_number = "0" %}
7+
{% set build_number = 1 %}
88
{% set channel_targets = ('abc', 'def') %}
99
# this is just for the initial build, to break dependencies with python -> pip -> libpython-static
1010
{% set bootstrap = "false" %}
@@ -39,6 +39,10 @@
3939
{% set py_interp_debug = "no" %}
4040
{% endif %}
4141

42+
{% set rl_string = "" %} # [win or readline_mode == 'readline']
43+
{% set rl_string = "el_" %} # [not win and readline_mode == 'editline']
44+
{% set rl_string = "norl_" %} # [not win and readline_mode == 'none']
45+
4246
package:
4347
name: python-split
4448
version: {{ version }}{{ dev }}
@@ -88,9 +92,11 @@ source:
8892
{% if (openssl | string).startswith('1.1.1') %}
8993
- patches/0026-Use-OpenSSL-1_1-instead-of-3.patch
9094
{% endif %}
95+
- patches/0027-Fix-build-with-newer-editline.patch
9196

9297
build:
93-
number: {{ build_number }}
98+
number: {{ build_number + 100 }} # [win or readline_mode == 'readline']
99+
number: {{ build_number }} # [not(win or readline_mode == 'readline')]
94100

95101
requirements:
96102
build:
@@ -107,7 +113,9 @@ outputs:
107113
script: build_base.sh # [unix]
108114
script: build_base.bat # [win]
109115
build:
110-
number: {{ build_number }}
116+
number: {{ build_number + 200 }} # [win or readline_mode == 'readline']
117+
number: {{ build_number + 100 }} # [not win and readline_mode == 'editline']
118+
number: {{ build_number }} # [not win and readline_mode == 'none']
111119
activate_in_script: true
112120
# Windows has issues updating python if conda is using files itself.
113121
# Copy rather than link.
@@ -128,13 +136,13 @@ outputs:
128136
# - lib/python{{ ver2 }}/lib-dynload/_hashlib.cpython-{{ ver2nd }}-x86_64-linux-gnu.so # [linux]
129137
# - lib/libpython3.dylib # [osx]
130138
# match python.org compiler standard
131-
skip: true # [win and int(float(vc)) < 14]
139+
skip: true # [win and (int(float(vc)) < 14 or readline_mode != 'none')]
132140
{% if 'conda-forge' in channel_targets %}
133141
skip_compile_pyc:
134142
- '*.py' # [build_platform != target_platform]
135143
{% endif %}
136-
string: {{ dev_ }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython # ["conda-forge" in (channel_targets or "")]
137-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }} # ["conda-forge" not in (channel_targets or "")]
144+
string: {{ dev_ }}h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython # ["conda-forge" in (channel_targets or "")]
145+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }} # ["conda-forge" not in (channel_targets or "")]
138146
{% if 'conda-forge' in channel_targets %}
139147
run_exports:
140148
noarch:
@@ -145,6 +153,7 @@ outputs:
145153
script_env:
146154
- PY_INTERP_LINKAGE_NATURE={{ linkage_nature_env }}
147155
- PY_INTERP_DEBUG={{ py_interp_debug }}
156+
- READLINE_MODE={{ readline_mode }}
148157
# Putting these here means they get emitted to build_env_setup.{sh,bat} meaning we can launch IDEs
149158
# after sourcing or calling that script without examine the contents of conda_build.{sh,bat} for
150159
# important env. vars.
@@ -192,7 +201,8 @@ outputs:
192201
- xz
193202
- zlib
194203
- openssl
195-
- readline # [not win]
204+
- readline {{ readline }} # [readline_mode == 'readline']
205+
- libedit # [readline_mode == 'editline']
196206
- tk
197207
- ncurses # [unix]
198208
- libffi 3.4
@@ -291,15 +301,17 @@ outputs:
291301
script: build_static.sh # [unix]
292302
script: build_static.bat # [win]
293303
build:
294-
number: {{ build_number }}
304+
number: {{ build_number + 100 }} # [win or readline_mode == 'readline']
305+
number: {{ build_number }} # [not(win or readline_mode == 'readline')]
295306
activate_in_script: true
296307
{% if 'conda-forge' in channel_targets %}
297308
ignore_run_exports:
298309
- python_abi
299-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython
310+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython
300311
{% else %}
301-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}
302-
{% endif %}
312+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}
313+
{% endif %}mv
314+
skip: true # [win and readline_mode != 'none']
303315
requirements:
304316
build:
305317
- {{ compiler('c') }}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From 31b6aa76491e85b569119d0778809afe18c3384e Mon Sep 17 00:00:00 2001
2+
From: Bo Anderson <[email protected]>
3+
Date: Mon, 9 Oct 2023 14:21:20 +0100
4+
Subject: [PATCH] [3.11] gh-109191: Fix build with newer editline (gh-110239).
5+
(cherry picked from commit f4cb0d27cc08f490c42a22e646eb73cc7072d54a)
6+
7+
Co-authored-by: Bo Anderson <[email protected]>
8+
---
9+
...23-10-05-11-46-20.gh-issue-109191.imUkVN.rst | 1 +
10+
Modules/readline.c | 2 +-
11+
configure | 17 +++++++++++++++++
12+
configure.ac | 14 ++++++++++++++
13+
pyconfig.h.in | 3 +++
14+
5 files changed, 36 insertions(+), 1 deletion(-)
15+
create mode 100644 Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst
16+
17+
diff --git a/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst b/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst
18+
new file mode 100644
19+
index 00000000000000..27e5df790bc0c6
20+
--- /dev/null
21+
+++ b/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst
22+
@@ -0,0 +1 @@
23+
+Fix compile error when building with recent versions of libedit.
24+
diff --git a/Modules/readline.c b/Modules/readline.c
25+
index 27b89de7279464..8c7f526d418f82 100644
26+
--- a/Modules/readline.c
27+
+++ b/Modules/readline.c
28+
@@ -440,7 +440,7 @@ readline_set_completion_display_matches_hook_impl(PyObject *module,
29+
default completion display. */
30+
rl_completion_display_matches_hook =
31+
readlinestate_global->completion_display_matches_hook ?
32+
-#if defined(_RL_FUNCTION_TYPEDEF)
33+
+#if defined(HAVE_RL_COMPDISP_FUNC_T)
34+
(rl_compdisp_func_t *)on_completion_display_matches_hook : 0;
35+
#else
36+
(VFunction *)on_completion_display_matches_hook : 0;
37+
diff --git a/configure b/configure
38+
index af4a5bbfdfa1a4..b294f93a5564b4 100755
39+
--- a/configure
40+
+++ b/configure
41+
@@ -21289,6 +21289,23 @@ if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
42+
43+
$as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h
44+
45+
+fi
46+
+
47+
+
48+
+ # in readline as well as newer editline (April 2023)
49+
+ ac_fn_c_check_type "$LINENO" "rl_compdisp_func_t" "ac_cv_type_rl_compdisp_func_t" "
50+
+#include <stdio.h> /* Must be first for Gnu Readline */
51+
+#ifdef WITH_EDITLINE
52+
+# include <editline/readline.h>
53+
+#else
54+
+# include <readline/readline.h>
55+
+#endif
56+
+
57+
+"
58+
+if test "x$ac_cv_type_rl_compdisp_func_t" = xyes; then :
59+
+
60+
+$as_echo "#define HAVE_RL_COMPDISP_FUNC_T 1" >>confdefs.h
61+
+
62+
fi
63+
64+
fi
65+
diff --git a/configure.ac b/configure.ac
66+
index e1cbb7c7fbe9d9..629b7b76c3c315 100644
67+
--- a/configure.ac
68+
+++ b/configure.ac
69+
@@ -5918,6 +5918,20 @@ if test "$py_cv_lib_readline" = yes; then
70+
AC_CHECK_LIB($LIBREADLINE, append_history,
71+
AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
72+
[Define if readline supports append_history]),,$READLINE_LIBS)
73+
+
74+
+ # in readline as well as newer editline (April 2023)
75+
+ AC_CHECK_TYPE([rl_compdisp_func_t],
76+
+ [AC_DEFINE([HAVE_RL_COMPDISP_FUNC_T], [1],
77+
+ [Define if readline supports rl_compdisp_func_t])],
78+
+ [],
79+
+ [
80+
+#include <stdio.h> /* Must be first for Gnu Readline */
81+
+#ifdef WITH_EDITLINE
82+
+# include <editline/readline.h>
83+
+#else
84+
+# include <readline/readline.h>
85+
+#endif
86+
+ ])
87+
fi
88+
89+
# End of readline checks: restore LIBS
90+
diff --git a/pyconfig.h.in b/pyconfig.h.in
91+
index 0536047f573ce6..94d02e14c444ac 100644
92+
--- a/pyconfig.h.in
93+
+++ b/pyconfig.h.in
94+
@@ -968,6 +968,9 @@
95+
/* Define if you can turn off readline's signal handling. */
96+
#undef HAVE_RL_CATCH_SIGNAL
97+
98+
+/* Define if readline supports rl_compdisp_func_t */
99+
+#undef HAVE_RL_COMPDISP_FUNC_T
100+
+
101+
/* Define if you have readline 2.2 */
102+
#undef HAVE_RL_COMPLETION_APPEND_CHARACTER
103+

recipe/run_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@
8282
import fcntl
8383
import grp
8484
import nis
85-
import readline
8685
import resource
8786
import syslog
8887
import termios
8988

89+
if os.environ["READLINE_MODE"] != 'none':
90+
import readline
9091

9192
if not (armv6l or armv7l or ppc64le or osx105 or arm64):
9293
import tkinter

0 commit comments

Comments
 (0)