blob: 411d86f96b802efb6a82165c811a349e91c75866 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import cffi
ffi = cffi.FFI()
ffi.cdef("""
extern "Python" int add(int, int);
""", dllexport=True)
ffi.embedding_init_code("""
print "preparing" # printed once
@ffi.def_extern()
def add(x, y):
print "adding", x, "and", y
return x + y
""")
ffi.set_source("_embedding_cffi", """
""")
#ffi.compile() -- should be fixed to do the right thing
ffi.emit_c_code('_embedding_cffi.c')
# then call the compiler manually with the proper options, like:
# gcc -shared -fPIC _embedding_cffi.c -o _embedding_cffi.so -lpython2.7
# -I/usr/include/python2.7
|