[pypy-dev] how embed pypy into c?
Simon Liu
simohayha.bobo at gmail.com
Tue Mar 20 09:45:20 CET 2012
Hi.
On Tue, Mar 20, 2012 at 3:36 PM, Roberto De Ioris <roberto at unbit.it> wrote:
>
>
> > Hi all.
> >
> > I want to embed pypy into c code, but in pypy's directory, i don't find
> any pypy's c api, except in cypext directory.
> >
> > And I want to use stackless' c api too,. but i still have not found any
> stackless api(example stackless_api.h) in pypy.
> >
> > Thanks.
> >
> > --
> >
>
> Currently you are on your own.
>
> This is the step i follow:
>
> 1) patch genc.py to export RPython_StartupCode in addition to
> pypy_main_startup
>
> export_symbols=["pypy_main_startup", "RPython_StartupCode"]))
>
> and run:
>
> pypy translate.py -Ojit --shared
>
> to build libpypy
>
> 2) add this declaration on top of your code
>
> #ifdef UWSGI_PYPY
> char *RPython_StartupCode(void);
> #define pypy_asm_stack_bottom() asm volatile ("/* GC_STACK_BOTTOM */" : :
> : \
> "memory")
>
> #endif
>
> 3) instead of Py_Initialize() call
>
> pypy_asm_stack_bottom();
> RPython_StartupCode();
>
> After that you have an almost working pypy environment.
>
> A bunch of python c api functions are not implemented (but you will find
> it is pretty easy to add them, even as noop) so be prepared to some
> compromise.
>
> What kills me is the amount of time taken to rebuild the whole library, so
> i can work on it only on spare time (i am porting both mod_wsgi and uWSGI)
> :)
>
>
> --
> Roberto De Ioris
> http://unbit.it
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>
I have several problem(because compile pypy is slow ):
1 add "export_symbols=["pypy_main_startup", "RPython_StartupCode"]))" to
genc.py in which line? or top line?
2 this will export stackless c api?
Thanks.
--
do not fear to be eccentric in opinion, for every opinion now accepted was
once eccentric.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120320/9e1ecdc1/attachment-0001.html>
More information about the pypy-dev
mailing list