Hi, 2010/6/17 Ryan Kelly <[email protected]>: > > # Find the python DLL and extract needed functions > py = CDLL(libpython) > Py_Initialize = py.getpointer("Py_Initialize",[],ffi_type_void) > Py_Finalize = py.getpointer("Py_Finalize",[],ffi_type_void) > PyRun_SimpleString = > py.getpointer("PyRun_SimpleString",[ffi_type_pointer],ffi_type_sint) > > As you can imagine, the real application has a lot more of these > boilerplate declarations. Any suggestions on how to do this in > less/cleaner code?
For the cpyext module, we used the documentation to generate stubs for every function of the API. It's easy to write a sphinx extension that processes every "cfunction" directive in the documentation. You could start with pypy/module/cpyext/stubgen.py and modify it for your needs, which are obviously different. It's poorly documented, but the comment for r72933 says: The stub generator works as follows: 1. Go to Doc (in your CPython checkout). 2. Run make text and stop it after it downloaded the prerequisites. 3. Apply the patch Doc_stubgen_enable.patch in your CPython checkout 4. Run make text again with PyPy in your Python path. 5. Voila, the stubs.py file will be updated. -- Amaury Forgeot d'Arc _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
