[pypy-svn] r50475 - in pypy/dist/pypy: module/readline rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Wed Jan 9 23:51:51 CET 2008


Author: arigo
Date: Wed Jan  9 23:51:50 2008
New Revision: 50475

Modified:
   pypy/dist/pypy/module/readline/c_readline.py
   pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
(oesser, arigo)
Fight with readline until c_readline.py is happy on both Slackware's
and Gentoo's way of building the library.  (On Slackware, it is done
via "configure --with-curses".)


Modified: pypy/dist/pypy/module/readline/c_readline.py
==============================================================================
--- pypy/dist/pypy/module/readline/c_readline.py	(original)
+++ pypy/dist/pypy/module/readline/c_readline.py	Wed Jan  9 23:51:50 2008
@@ -4,12 +4,30 @@
 from pypy.interpreter.gateway import ObjSpace, interp2app
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
-# at least on Gentoo Linux, readline.h doesn't compile if stdio.h is not
-# included before
-eci = ExternalCompilationInfo(
-    includes = ["stdio.h", "readline/readline.h", "readline/history.h"],
-    libraries = ['readline']
-)
+# On various platforms, linking only with libreadline is not enough;
+# we also need to link with some variant of curses or libtermcap.
+# We follow the logic of CPython below.
+def try_with_lib(extralibs, **kwds):
+    # at least on Gentoo Linux, readline.h doesn't compile if stdio.h is not
+    # included before
+    eci = ExternalCompilationInfo(
+        includes = ["stdio.h", "readline/readline.h", "readline/history.h"],
+        libraries = extralibs + ['readline'],
+        )
+    if platform.check_eci(eci):
+        return eci
+    else:
+        return None
+
+eci = (try_with_lib([]) or
+       try_with_lib(['ncursesw']) or
+       try_with_lib(['ncurses']) or
+       try_with_lib(['curses']) or
+       try_with_lib(['termcap'], library_dirs=['/usr/lib/termcap']))
+if eci is None:
+    raise Exception("cannot find how to link to the readline library")
+
+# ____________________________________________________________
 
 def external(name, args, result):
     return rffi.llexternal(name, args, result, compilation_info=eci)

Modified: pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py	Wed Jan  9 23:51:50 2008
@@ -548,7 +548,8 @@
                 libpath = libname
             if libpath:
                 dllclass = getattr(ctypes, calling_conv + 'dll')
-                clib = dllclass.LoadLibrary(libpath)
+		# urgh, cannot pass the flag to dllclass.LoadLibrary
+                clib = dllclass._dlltype(libpath, ctypes.RTLD_GLOBAL)
                 cfunc = get_on_lib(clib, funcname)
                 if cfunc is not None:
                     break



More information about the Pypy-commit mailing list