Hi everyone, i have finally managed to have a pypy plugin into uWSGI via
libpypy-c.

The first step was exporting a bunch of symbols in libpypy-c:

"RPython_StartupCode", "pypy_g_ObjSpace_startup", "pypy_g_call_startup",
"pypy_g_State_startup", "pypy_g_Module_startup",
"pypy_g_pypy_module_cpyext_state_State"

pypy_g_ObjSpace_startup and pypy_g_Module_startup are not strictly
required, i have used them only for debugging some very specific areas.

Attached there is a patch for latest tip.

After that, i have defined a Py_Initialize() replacement:

http://projects.unbit.it/uwsgi/browser/plugins/python/python_plugin.c#L8

and placed a bunch of #ifdef for unsupported functions
(like PyFile_FromFile)

Finally i have built libpypy with

pypy translate.py -Ojit --shared

and the uWSGI plugin with

LDFLAGS="-L." pypy-c uwsgiconfig.py --plugin plugins/pypy core

(LDFLAGS is used as i have libpypy-c in the current dir)

Run uWSGI with the welcome app (and a bunch of processes):

uwsgi --http-socket :8080 --plugin pypy --module welcome --master
--processes 8

Incredibly the whole uwsgi api (that it is pretty complex, involving tons
of c code) works flawlessly as well as the custom wsgi.input object (the
whole upload test suite passes).

Running python threads from the WSGI app works too, but mapping python
threads to already available pthreads is a no go (all explodes, i will
investigate on that)

Importing applications as modules works normally, but importing via file
requires implementing a bunch of c-api in pypy (i will address that soon)

virtualenv, sys.argv and setting programname is not supported (no c api
available) i can get rid of this too in the next few days.

Important thing: i have tested it only on OSX

-- 
Roberto De Ioris
http://unbit.it

Attachment: libpypy_export.patch
Description: Binary data

_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to