Skip to content

Commit 7db4345

Browse files
author
Rafael Martins
committed
Add no readline variants
1 parent 0a624d2 commit 7db4345

File tree

6 files changed

+146
-13
lines changed

6 files changed

+146
-13
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
@@ -252,6 +252,14 @@ _common_configure_args+=(--with-tcltk-includes="-I${PREFIX}/include")
252252
_common_configure_args+=("--with-tcltk-libs=-L${PREFIX}/lib -ltcl8.6 -ltk8.6")
253253
_common_configure_args+=(--with-platlibdir=lib)
254254

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

recipe/conda_build_config.yaml

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

recipe/meta.yaml

Lines changed: 22 additions & 10 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

1010
# this makes the linter happy
@@ -37,6 +37,10 @@
3737
{% set py_interp_debug = "no" %}
3838
{% endif %}
3939

40+
{% set rl_string = "" %} # [win or readline_mode == 'readline']
41+
{% set rl_string = "el_" %} # [not win and readline_mode == 'editline']
42+
{% set rl_string = "norl_" %} # [not win and readline_mode == 'none']
43+
4044
package:
4145
name: python-split
4246
version: {{ version }}{{ dev }}
@@ -87,9 +91,11 @@ source:
8791
{% if (openssl | string).startswith('3.0') %}
8892
- patches/0026-Use-OpenSSL-3-instead-of-1_1.patch
8993
{% endif %}
94+
- patches/0027-Fix-build-with-newer-editline.patch
9095

9196
build:
92-
number: {{ build_number }}
97+
number: {{ build_number + 100 }} # [win or readline_mode == 'readline']
98+
number: {{ build_number }} # [not(win or readline_mode == 'readline')]
9399

94100
requirements:
95101
build:
@@ -106,7 +112,9 @@ outputs:
106112
script: build_base.sh # [unix]
107113
script: build_base.bat # [win]
108114
build:
109-
number: {{ build_number }}
115+
number: {{ build_number + 200 }} # [win or readline_mode == 'readline']
116+
number: {{ build_number + 100 }} # [not win and readline_mode == 'editline']
117+
number: {{ build_number }} # [not win and readline_mode == 'none']
110118
activate_in_script: true
111119
# Windows has issues updating python if conda is using files itself.
112120
# Copy rather than link.
@@ -127,13 +135,13 @@ outputs:
127135
# - lib/python{{ ver2 }}/lib-dynload/_hashlib.cpython-{{ ver2nd }}-x86_64-linux-gnu.so # [linux]
128136
# - lib/libpython3.dylib # [osx]
129137
# match python.org compiler standard
130-
skip: true # [win and int(float(vc)) < 14]
138+
skip: true # [win and (int(float(vc)) < 14 or readline_mode != 'none')]
131139
{% if 'conda-forge' in channel_targets %}
132140
skip_compile_pyc:
133141
- '*.py' # [build_platform != target_platform]
134142
{% endif %}
135-
string: {{ dev_ }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython # ["conda-forge" in (channel_targets or "")]
136-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }} # ["conda-forge" not in (channel_targets or "")]
143+
string: {{ dev_ }}h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython # ["conda-forge" in (channel_targets or "")]
144+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }} # ["conda-forge" not in (channel_targets or "")]
137145
{% if 'conda-forge' in channel_targets %}
138146
run_exports:
139147
noarch:
@@ -144,6 +152,7 @@ outputs:
144152
script_env:
145153
- PY_INTERP_LINKAGE_NATURE={{ linkage_nature_env }}
146154
- PY_INTERP_DEBUG={{ py_interp_debug }}
155+
- READLINE_MODE={{ readline_mode }}
147156
# Putting these here means they get emitted to build_env_setup.{sh,bat} meaning we can launch IDEs
148157
# after sourcing or calling that script without examine the contents of conda_build.{sh,bat} for
149158
# important env. vars.
@@ -193,7 +202,8 @@ outputs:
193202
- xz
194203
- zlib
195204
- openssl
196-
- readline # [not win]
205+
- readline {{ readline }} # [readline_mode == 'readline']
206+
- libedit # [readline_mode == 'editline']
197207
- tk
198208
- ncurses # [unix]
199209
- libffi 3.4
@@ -290,15 +300,17 @@ outputs:
290300
script: build_static.sh # [unix]
291301
script: build_static.bat # [win]
292302
build:
293-
number: {{ build_number }}
303+
number: {{ build_number + 100 }} # [win or readline_mode == 'readline']
304+
number: {{ build_number }} # [not(win or readline_mode == 'readline')]
294305
activate_in_script: true
295306
{% if 'conda-forge' in channel_targets %}
296307
ignore_run_exports:
297308
- python_abi
298-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython
309+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython
299310
{% else %}
300-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}
311+
string: h{{ PKG_HASH }}_{{ rl_string }}{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}
301312
{% endif %}
313+
skip: true # [win and readline_mode != 'none']
302314
requirements:
303315
build:
304316
- {{ compiler('c') }}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From a2fccb5e07017f32e116678ab0bf310abb494fdb Mon Sep 17 00:00:00 2001
2+
From: Rafael Martins <[email protected]>
3+
Date: Thu, 1 Feb 2024 23:09:15 +0100
4+
Subject: [PATCH] Fix build with newer editline
5+
6+
---
7+
Modules/readline.c | 2 +-
8+
configure | 17 +++++++++++++++++
9+
configure.ac | 14 ++++++++++++++
10+
pyconfig.h.in | 3 +++
11+
4 files changed, 35 insertions(+), 1 deletion(-)
12+
13+
diff --git a/Modules/readline.c b/Modules/readline.c
14+
index 1d50672..236b11c 100644
15+
--- a/Modules/readline.c
16+
+++ b/Modules/readline.c
17+
@@ -438,7 +438,7 @@ readline_set_completion_display_matches_hook_impl(PyObject *module,
18+
default completion display. */
19+
rl_completion_display_matches_hook =
20+
readlinestate_global->completion_display_matches_hook ?
21+
-#if defined(_RL_FUNCTION_TYPEDEF)
22+
+#if defined(HAVE_RL_COMPDISP_FUNC_T)
23+
(rl_compdisp_func_t *)on_completion_display_matches_hook : 0;
24+
#else
25+
(VFunction *)on_completion_display_matches_hook : 0;
26+
diff --git a/configure b/configure
27+
index 4b71c4e..d5c0e1c 100755
28+
--- a/configure
29+
+++ b/configure
30+
@@ -16158,6 +16158,23 @@ if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
31+
32+
$as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h
33+
34+
+fi
35+
+
36+
+
37+
+ # in readline as well as newer editline (April 2023)
38+
+ ac_fn_c_check_type "$LINENO" "rl_compdisp_func_t" "ac_cv_type_rl_compdisp_func_t" "
39+
+#include <stdio.h> /* Must be first for Gnu Readline */
40+
+#ifdef WITH_EDITLINE
41+
+# include <editline/readline.h>
42+
+#else
43+
+# include <readline/readline.h>
44+
+#endif
45+
+
46+
+"
47+
+if test "x$ac_cv_type_rl_compdisp_func_t" = xyes; then :
48+
+
49+
+$as_echo "#define HAVE_RL_COMPDISP_FUNC_T 1" >>confdefs.h
50+
+
51+
fi
52+
53+
fi
54+
diff --git a/configure.ac b/configure.ac
55+
index ac3be38..87af1e4 100644
56+
--- a/configure.ac
57+
+++ b/configure.ac
58+
@@ -5060,6 +5060,20 @@ if test "$py_cv_lib_readline" = yes; then
59+
AC_CHECK_LIB($LIBREADLINE, append_history,
60+
AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
61+
[Define if readline supports append_history]),,$READLINE_LIBS)
62+
+
63+
+ # in readline as well as newer editline (April 2023)
64+
+ AC_CHECK_TYPE([rl_compdisp_func_t],
65+
+ [AC_DEFINE([HAVE_RL_COMPDISP_FUNC_T], [1],
66+
+ [Define if readline supports rl_compdisp_func_t])],
67+
+ [],
68+
+ [
69+
+#include <stdio.h> /* Must be first for Gnu Readline */
70+
+#ifdef WITH_EDITLINE
71+
+# include <editline/readline.h>
72+
+#else
73+
+# include <readline/readline.h>
74+
+#endif
75+
+ ])
76+
fi
77+
78+
# End of readline checks: restore LIBS
79+
diff --git a/pyconfig.h.in b/pyconfig.h.in
80+
index 57c84e5..6d4f5fc 100644
81+
--- a/pyconfig.h.in
82+
+++ b/pyconfig.h.in
83+
@@ -866,6 +866,9 @@
84+
/* Define if you can turn off readline's signal handling. */
85+
#undef HAVE_RL_CATCH_SIGNAL
86+
87+
+/* Define if readline supports rl_compdisp_func_t */
88+
+#undef HAVE_RL_COMPDISP_FUNC_T
89+
+
90+
/* Define if you have readline 2.2 */
91+
#undef HAVE_RL_COMPLETION_APPEND_CHARACTER
92+
93+
--
94+
2.39.2 (Apple Git-143)
95+

recipe/run_test.py

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

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

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

0 commit comments

Comments
 (0)