[pypy-commit] pypy py3k: Add a fallback to the ncurses library if ncursesw is not available.

mjacob noreply at buildbot.pypy.org
Thu Jun 11 01:47:02 CEST 2015


Author: Manuel Jacob <me at manueljacob.de>
Branch: py3k
Changeset: r78022:2705fe4f9105
Date: 2015-06-11 01:47 +0200
http://bitbucket.org/pypy/pypy/changeset/2705fe4f9105/

Log:	Add a fallback to the ncurses library if ncursesw is not available.

diff --git a/lib_pypy/_curses_build.py b/lib_pypy/_curses_build.py
--- a/lib_pypy/_curses_build.py
+++ b/lib_pypy/_curses_build.py
@@ -1,4 +1,22 @@
-from cffi import FFI
+from cffi import FFI, VerificationError
+
+
+def find_curses_library():
+    for curses_library in ['ncursesw', 'ncurses']:
+        ffi = FFI()
+        ffi.set_source("_curses_cffi_check", "", libraries=[curses_library])
+        try:
+            ffi.compile()
+        except VerificationError as e:
+            e_last = e
+            continue
+        else:
+            return curses_library
+
+    # If none of the libraries is available, present the user a meaningful
+    # error message
+    raise e_last
+
 
 ffi = FFI()
 
@@ -41,7 +59,7 @@
 void _m_getsyx(int *yx) {
     getsyx(yx[0], yx[1]);
 }
-""", libraries=['ncursesw', 'panel'])
+""", libraries=[find_curses_library(), 'panel'])
 
 
 ffi.cdef("""


More information about the pypy-commit mailing list