cffi generated xxx.pypy-26.so or xxx.pypy-41.so

42 views
Skip to first unread message

Yang Neil

unread,
Mar 13, 2016, 5:43:17 AM3/13/16
to python-cffi
I am using cffi+pypy to link with C code in my project under the Windows platform.
Because I'm using the MinGW gcc. It has some trouble if I use ffi.compile() directly (it assumes I use the MSC),
so I need to use ffi.emit_c_code('xxx.c') to generate the C code, then use gcc and linker to link with my C libraries.

The cffi generated .so file used to be named xxx.pypy-26.so if it runs with pypy 4.0.1.
But now I update the pypy to pypy 5.0.0, the .so name becomes xxx.pypy-41.so

I know if I use the ffi.compile(), it will generate the .so with the correct name automatically.
But if I need to use ffi.emit_c_code() then compile/link it with GCC so I need to give the .so name by myself.
Is there an easy way to determine the .so name I should give? (pypy-26 or pypy-41 or others if use future pypy version)

Armin Rigo

unread,
Mar 13, 2016, 6:15:28 AM3/13/16
to pytho...@googlegroups.com
Hi Yang,

On 13 March 2016 at 10:43, Yang Neil <kpws...@gmail.com> wrote:
> Is there an easy way to determine the .so name I should give? (pypy-26 or
> pypy-41 or others if use future pypy version)

Yes, in both PyPy and CPython the "extension" can be found by reading
``imp.get_suffixes()``, looking for the first tuple that ends with 3
(==imp.C_EXTENSION). On PyPy it gives something like ``.pypy-41.so``.
It should also return the correct platform's suffix: not always
``.so``.


A bientôt,

Armin.

Yang Neil

unread,
Mar 13, 2016, 8:45:07 AM3/13/16
to python-cffi, ar...@tunes.org
Hi Armin,

This is what I need!
Thank you very much.

Neil

Armin Rigo於 2016年3月13日星期日 UTC+8下午6時15分28秒寫道:
Reply all
Reply to author
Forward
0 new messages