[pypy-svn] r28360 - in pypy/dist/pypy: doc doc/discussion module/readline module/readline/test

hpk at codespeak.net hpk at codespeak.net
Tue Jun 6 12:50:05 CEST 2006


Author: hpk
Date: Tue Jun  6 12:50:05 2006
New Revision: 28360

Added:
   pypy/dist/pypy/module/readline/
   pypy/dist/pypy/module/readline/__init__.py
      - copied, changed from r28353, pypy/dist/pypy/doc/discussion/readline.py
   pypy/dist/pypy/module/readline/c_readline.py   (contents, props changed)
   pypy/dist/pypy/module/readline/interp_readline.py
      - copied, changed from r28353, pypy/dist/pypy/doc/discussion/readline.py
   pypy/dist/pypy/module/readline/test/
   pypy/dist/pypy/module/readline/test/__init__.py   (contents, props changed)
   pypy/dist/pypy/module/readline/test/test_readline.py   (contents, props changed)
Removed:
   pypy/dist/pypy/doc/discussion/readline.py
Modified:
   pypy/dist/pypy/doc/extcompiler.txt
Log:
(arre,hpk) refinements/new directory structure for readline example + extcompiler draft documentation


Modified: pypy/dist/pypy/doc/extcompiler.txt
==============================================================================
--- pypy/dist/pypy/doc/extcompiler.txt	(original)
+++ pypy/dist/pypy/doc/extcompiler.txt	Tue Jun  6 12:50:05 2006
@@ -25,26 +25,38 @@
 writing a module (provide example)
 +++++++++++++++++++++++++++++++++++++++++
 
-see `pypy/module/readline.py`_ 
+You have to put your module into its own directory in `pypy/module/`_ 
+of your local `pypy checkout`_. 
 
-XXX testing a module 
-XXX translating a module (to CPython extension) 
-XXX integration as a PyPy module 
+see `pypy/module/readline`_ for an example. 
+
+XXX describe directory structure here 
 
-translating a module 
+testing a module 
 ++++++++++++++++++++++++
 
+::
+    python2.4 pypy/test_all.py pypy/module/readline/test/test_readline.py 
+
+or::
+    py.test pypy/module/readline/test/test_readline.py 
+
+# XXX 
+
+`pypy/module/readline/test/test_readline.py`_. 
+
+
+translating a module to a CPython extension
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+
 :: 
-    python2.4 pypy/bin/extcompiler.py path/to/readline.py 
+    python2.4 pypy/bin/extcompiler.py readline  #<needs to be in module dir
 
 The extension compiler imports the specified module/package 
 and produces a shared library importable from your local 
 python2.4 installation.  The produced shared library is 
 put into the current working directory by default. 
 
-XXX think about isolation (to only import the specified file and 
-    not implicitely include the parent directory in sys.path) 
-
 XXX think about shared state of imported modules (e.g. linecache
     or other modules which might get imported from the ext-package) 
 
@@ -54,6 +66,9 @@
     supportpackage/somecode.py 
 
 
+XXX integration as a PyPy module 
+
+
 
 
 Installation notes requirements 

Added: pypy/dist/pypy/module/readline/c_readline.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/readline/c_readline.py	Tue Jun  6 12:50:05 2006
@@ -0,0 +1,28 @@
+from pypy.module.readline import Module 
+import ctypes
+
+#------------------------------------------------------------
+# configuration for binding to external readline library 
+# through rctypes
+#
+class CConfig:
+    _header_ = """#include <readline/readline.h>"""
+    _libraries_ = ('readline',)
+
+cconfig = Module.cconfig(CConfig)
+
+libreadline = cconfig.ctypes_lib['readline']
+
+c_readline = libreadline.readline
+c_readline.restype = ctypes.c_char_p
+
+c_rl_initialize = libreadline.rl_initiliaze 
+c_rl_initialize.argtypes = []
+#c_rl_initialize.restype = void 
+
+#------------------------------------------------------------
+# special initialization of readline 
+
+def setup_readline(space): 
+    # XXX ... 
+    c_rl_initialize()

Added: pypy/dist/pypy/module/readline/test/__init__.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/readline/test/__init__.py	Tue Jun  6 12:50:05 2006
@@ -0,0 +1 @@
+#

Added: pypy/dist/pypy/module/readline/test/test_readline.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/readline/test/test_readline.py	Tue Jun  6 12:50:05 2006
@@ -0,0 +1,10 @@
+
+
+def setup_mod(mod):
+    #mod.space = StdObjSpace(usemodules=['readline'])
+    mod.space = CPyObjSpace(usemodules=['readline'])
+
+def app_test_basic_import():
+    import readline 
+    readline.set_completer 
+    # test more 



More information about the Pypy-commit mailing list