Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c26b7ba

Browse files
committedJul 1, 2024··
[3.12] pythongh-113565: Improve and harden detection of curses dependencies (python#119816)
(cherry picked from commit f80376b) 1. Use pkg-config to check for ncursesw/panelw. If that fails, use pkg-config to check for ncurses/panel. 2. Regardless of pkg-config output, search for curses/panel headers, so we're sure we have all defines in pyconfig.h. 3. Regardless of pkg-config output, check if libncurses or libncursesw contains the 'initscr' symbol; if it does _and_ pkg-config failed earlier, add the resulting -llib linker option to CURSES_LIBS. Ditto for 'update_panels' and PANEL_LIBS. 4. Wrap the rest of the checks with WITH_SAVE_ENV and make sure we're using updated LIBS and CPPFLAGS for those. Add the PY_CHECK_CURSES convenience macro.
1 parent e2a97d1 commit c26b7ba

File tree

7 files changed

+596
-726
lines changed

7 files changed

+596
-726
lines changed
 

‎Include/py_curses.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@
3030
#define NCURSES_OPAQUE 0
3131
#endif
3232

33-
#ifdef HAVE_NCURSES_H
34-
#include <ncurses.h>
35-
#else
36-
#include <curses.h>
33+
#if defined(HAVE_NCURSESW_NCURSES_H)
34+
# include <ncursesw/ncurses.h>
35+
#elif defined(HAVE_NCURSESW_CURSES_H)
36+
# include <ncursesw/curses.h>
37+
#elif defined(HAVE_NCURSES_NCURSES_H)
38+
# include <ncurses/ncurses.h>
39+
#elif defined(HAVE_NCURSES_CURSES_H)
40+
# include <ncurses/curses.h>
41+
#elif defined(HAVE_NCURSES_H)
42+
# include <ncurses.h>
43+
#elif defined(HAVE_CURSES_H)
44+
# include <curses.h>
3745
#endif
3846

39-
#ifdef HAVE_NCURSES_H
47+
#ifdef NCURSES_VERSION
4048
/* configure was checking <curses.h>, but we will
4149
use <ncurses.h>, which has some or all these features. */
4250
#if !defined(WINDOW_HAS_FLAGS) && !(NCURSES_OPAQUE+0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve :mod:`curses` and :mod:`curses.panel` dependency checks in
2+
:program:`configure`.

‎Modules/_curses_panel.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ static const char PyCursesVersion[] = "2.1";
1414

1515
#include "py_curses.h"
1616

17-
#include <panel.h>
17+
#if defined(HAVE_NCURSESW_PANEL_H)
18+
# include <ncursesw/panel.h>
19+
#elif defined(HAVE_NCURSES_PANEL_H)
20+
# include <ncurses/panel.h>
21+
#elif defined(HAVE_PANEL_H)
22+
# include <panel.h>
23+
#endif
1824

1925
typedef struct {
2026
PyObject *PyCursesError;

‎Modules/_cursesmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static const char PyCursesVersion[] = "2.2";
130130
#include <langinfo.h>
131131
#endif
132132

133-
#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5))
133+
#if !defined(NCURSES_VERSION) && (defined(sgi) || defined(__sun) || defined(SCO5))
134134
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
135135
typedef chtype attr_t; /* No attr_t type is available */
136136
#endif
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.