[3.14] gh-155911: Fix curses detection with libraries in LIBS (GH-156130) (GH-156224)

serhiy-storchaka <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/90235cbe4b8cfd101963c5aabc2fe5c49783d163
commit: 90235cbe4b8cfd101963c5aabc2fe5c49783d163
branch: 3.14
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-22T12:08:10+03:00
summary:

[3.14] gh-155911: Fix curses detection with libraries in LIBS (GH-156130) (GH-156224)

AC_SEARCH_LIBS tries linking with no extra library first, so a curses
library already in LIBS made the search report "none required", which
then became the module's link flag.  Search with only the libraries the
module is linked with.
(cherry picked from commit f74cdf80a120649e4c353430da8cbd1305c00993)

Co-authored-by: Shamil <[email protected]>

files:
A Misc/NEWS.d/next/Build/2026-08-20-17-41-11.gh-issue-155911.yL3z8q.rst
M configure
M configure.ac

diff --git a/Misc/NEWS.d/next/Build/2026-08-20-17-41-11.gh-issue-155911.yL3z8q.rst b/Misc/NEWS.d/next/Build/2026-08-20-17-41-11.gh-issue-155911.yL3z8q.rst
new file mode 100644
index 00000000000000..ec3c798995849b
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-08-20-17-41-11.gh-issue-155911.yL3z8q.rst
@@ -0,0 +1,2 @@
+Fix curses detection when a curses library is already in ``LIBS``.
+Patch by Shamil Abdulaev.
diff --git a/configure b/configure
index 1124cb09dd23d3..88f235951b6551 100755
--- a/configure
+++ b/configure
@@ -28785,8 +28785,9 @@ fi
 
 
   # Check that we're able to link with crucial curses/panel functions. This
-  # also serves as a fallback in case pkg-config failed.
-  as_fn_append LIBS " $CURSES_LIBS $PANEL_LIBS"
+  # also serves as a fallback in case pkg-config failed. Extension modules are
+  # not linked with LIBS, so exclude it to get the required libraries.
+  LIBS="$CURSES_LIBS $PANEL_LIBS"
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing initscr" >&5
 printf %s "checking for library containing initscr... " >&6; }
 if test ${ac_cv_search_initscr+y}
diff --git a/configure.ac b/configure.ac
index 10a5f25dffdbb6..a082848c50ca37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6952,8 +6952,9 @@ WITH_SAVE_ENV([
   ]))
 
   # Check that we're able to link with crucial curses/panel functions. This
-  # also serves as a fallback in case pkg-config failed.
-  AS_VAR_APPEND([LIBS], [" $CURSES_LIBS $PANEL_LIBS"])
+  # also serves as a fallback in case pkg-config failed. Extension modules are
+  # not linked with LIBS, so exclude it to get the required libraries.
+  LIBS="$CURSES_LIBS $PANEL_LIBS"
   AC_SEARCH_LIBS([initscr], [ncursesw ncurses],
     [AS_VAR_IF([have_curses], [no],
       [AS_VAR_SET([have_curses], [yes])

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.