Skip to content

gh-136687: allow manually excluding ncurses from the build#136696

Closed
duaneg wants to merge 6 commits into
python:mainfrom
duaneg:gh-136687
Closed

gh-136687: allow manually excluding ncurses from the build#136696
duaneg wants to merge 6 commits into
python:mainfrom
duaneg:gh-136687

Conversation

@duaneg

@duaneg duaneg commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

Add an option to manually exclude ncurses from the build.

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't forget to update Doc/using/configure.rst with the new option.

I haven't reviewed the AC code, because I am not an expert there :)

Comment thread Misc/NEWS.d/next/Build/2025-07-16-11-41-43.gh-issue-136687.ob_uIp.rst Outdated
…pping

building the python curses module as opposed to not using the system ncurses
library.

Remove mistakenly repeated test modules section.

Document configure option.
@duaneg

duaneg commented Jul 20, 2025

Copy link
Copy Markdown
Contributor Author

Please, don't forget to update Doc/using/configure.rst with the new option.

Ah, thanks! I didn't spot those docs, updated. On review I think it would be better to think of this from the higher-level user perspective of excluding the curses module, rather than the lower-level build perspective of "skipping a system library check". I've renamed the option --disable-curses, instead of disable-ncurses, accordingly.

Although that does prompt the question of whether we should allow excluding other modules at build time. I'm not sure if this has been discussed before or would be considered useful.

I haven't reviewed the AC code, because I am not an expert there :)

As it turns out, I had made a silly mistake and left a copy & pasted chunk of code in there, so I'm glad you didn't review it as yet 🙂

A tip for reviewing: most of the configure.ac changes are making the libncurses checks conditional, and hence mostly just change indentation. If you review them ignoring whitespace the diff is much easier to read.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 27, 2026

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve conflicts. A large amount of probes was added recently.

Comment thread Doc/using/configure.rst Outdated
Comment thread configure.ac Outdated
Comment thread configure.ac Outdated
AC_ARG_ENABLE([curses], [AS_HELP_STRING(
[--disable-curses],
[disable building curses module (default is no)])], [
AS_VAR_IF([enable_curses], [yes], [Py_CHECK_NCURSES=yes], [Py_CHECK_NCURSES=no])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"curses" or "ncurses"? Inconsistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One ("curses") refers to the python module (whether to build it or not), while the other ("ncurses") refers to the system library (whether to look for it or not), so it is the referents that are inconsistent. I thought a higher-level option was better as a configure flag, with the existing system library check variable being essentially an implementation detail.

However, the inconsistency isn't ideal, agreed. If you prefer I'll switch the configure option back to ncurses. Or add a comment, if that would suffice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system library is not necessary ncurses.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 1, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33408292 | 📁 Comparing 3a14940 against main (34503f3)

  🔍 Preview build  

4 files changed
± c-api/module.html
± library/imaplib.html
± using/configure.html
± whatsnew/changelog.html

@serhiy-storchaka

Copy link
Copy Markdown
Member

I am sorry, but I changed the configure file again, breaking your PR.

Resolve conflicts in configure.ac/configure: the curses probes added on main
(nofilter, has_mouse, is_keypad, is_leaveok, new_prescr, use_screen, use_window,
key_defined, term_attrs, define_key, keyok, set_escdelay, set_tabsize, the
getmouse X/Open signature check, ESCDELAY/TABSIZE, scr_dump) now sit inside the
new --disable-curses (Py_CHECK_NCURSES) conditional, so they are skipped when
curses is disabled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka

Copy link
Copy Markdown
Member

I have resolved conflicts, but the question about ncurses remains.

@duaneg

duaneg commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I have resolved conflicts, but the question about ncurses remains.

Thanks very much and apologies I hadn't done it myself: I got partway last night but ran out of time. Regarding the naming: I am very happy to change the variable name, perhaps something like Py_ENABLE_CURSES would be better?

@serhiy-storchaka

Copy link
Copy Markdown
Member

This is not the name of a macro exposed in C. AC_ARG_ENABLE([curses]) already creates enable_curses (yes/no/unset). We can use it.

AC_ARG_ENABLE([curses],
  [AS_HELP_STRING([--disable-curses], [don't build the curses module (default: enabled)])])
AS_VAR_IF([enable_curses], [no], [], [enable_curses=yes])

@duaneg

duaneg commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

This is not the name of a macro exposed in C. AC_ARG_ENABLE([curses]) already creates enable_curses (yes/no/unset). We can use it.

Ah, I see, indeed! Thanks 🙂

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 3, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Thanks @duaneg for the patch, and @dilyanpalauzov for the report.

I went with a slightly broader approach in #153992: rather than a boolean --disable-curses, it adds --with-curses=ncursesw|ncurses|curses|no, mirroring --with-readline. --without-curses (i.e. --with-curses=no) does exactly what this PR does — it excludes the curses and _curses_panel modules regardless of what libraries are installed — so the original request is covered. On top of that it lets you pin the backend explicitly and, notably, build against the system's native curses (e.g. on NetBSD or Solaris), which configure previously couldn't reach at all.

Since it supersedes this PR I'd like to close this one — but thank you, it's what prompted the wider change. Could you take a look at #153992 and let me know if anything's missing?

@duaneg

duaneg commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Since it supersedes this PR I'd like to close this one — but thank you, it's what prompted the wider change. Could you take a look at #153992 and let me know if anything's missing?

LGTM and thanks very much for the much more comprehensive fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants