Skip to content

Commit

Permalink
Install ncurses from Homebrew, if available
Browse files Browse the repository at this point in the history
XCode Command Line Tools 15.0 was recently released, and it contains a
broken version of ncurses 6.0. Some uses of Python's `curses` module
will segfault when compiled with it. The solution is to switch to using
the version of ncurses from Homebrew, which is currently 6.4. Support
for ncurses 6 was added to Python 3.7 and was backported to 3.6 and 2.7,
so this change should not break any recently supported Python versions.

See python/cpython#109617 and
python/cpython#69906 for more information.
  • Loading branch information
aphedges committed Oct 5, 2023
1 parent 44c8f06 commit 5c081c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/python-build/bin/python-build
Expand Up @@ -803,6 +803,7 @@ build_package_standard_build() {
use_homebrew || true
use_tcltk || true
use_homebrew_readline || use_freebsd_pkg || true
use_homebrew_ncurses || true
if is_mac -ge 1014; then
use_xcode_sdk_zlib || use_homebrew_zlib || true
else
Expand Down Expand Up @@ -1468,6 +1469,18 @@ use_homebrew_readline() {
fi
}

use_homebrew_ncurses() {
can_use_homebrew || return 1
local libdir="$(brew --prefix ncurses 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "python-build: use ncurses from homebrew"
export CPPFLAGS="-I$libdir/include${CPPFLAGS:+ $CPPFLAGS}"
export LDFLAGS="-L$libdir/lib${LDFLAGS:+ $LDFLAGS}"
else
return 1
fi
}

prefer_openssl11() {
# Allow overriding the preference of OpenSSL version per definition basis (#1302, #1325, #1326)
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA="${PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA:-openssl@1.1 openssl}"
Expand Down

0 comments on commit 5c081c8

Please sign in to comment.