def make_mod(tmpdir):
     c_file = os.path.join(tmpdir, module_name + source_extension)
     log.info("generating cffi module %r" % c_file)
     mkpath(tmpdir)
     updated = recompiler.make_c_source(ffi, module_name, source, c_file)
     if not updated:
         log.info("already up-to-date")
     return c_file
示例#2
0
 def make_mod(tmpdir):
     c_file = os.path.join(tmpdir, module_name + source_extension)
     log.info("generating cffi module %r" % c_file)
     mkpath(tmpdir)
     updated = recompiler.make_c_source(ffi, module_name, source, c_file)
     if not updated:
         log.info("already up-to-date")
     return c_file
 def make_mod(tmpdir, pre_run=None):
     c_file = os.path.join(tmpdir, module_name + source_extension)
     log.info("generating cffi module %r" % c_file)
     mkpath(tmpdir)
     # a setuptools-only, API-only hook: called with the "ext" and "ffi"
     # arguments just before we turn the ffi into C code.  To use it,
     # subclass the 'distutils.command.build_ext.build_ext' class and
     # add a method 'def pre_run(self, ext, ffi)'.
     if pre_run is not None:
         pre_run(ext, ffi)
     updated = recompiler.make_c_source(ffi, module_name, source, c_file)
     if not updated:
         log.info("already up-to-date")
     return c_file
示例#4
0
 def make_mod(tmpdir, pre_run=None):
     c_file = os.path.join(tmpdir, module_name + source_extension)
     log.info("generating cffi module %r" % c_file)
     mkpath(tmpdir)
     # a setuptools-only, API-only hook: called with the "ext" and "ffi"
     # arguments just before we turn the ffi into C code.  To use it,
     # subclass the 'distutils.command.build_ext.build_ext' class and
     # add a method 'def pre_run(self, ext, ffi)'.
     if pre_run is not None:
         pre_run(ext, ffi)
     updated = recompiler.make_c_source(ffi, module_name, source, c_file)
     if not updated:
         log.info("already up-to-date")
     return c_file
from cffi import FFI
from cffi import recompiler

#It wraps main c code with python stuff.
with open('src/main.c') as source, open('src/definitions.h') as definitions:
	# pass source code to CFFI
	ffibuilder = FFI()
	ffibuilder.cdef(definitions.read())
	recompiler.make_c_source(ffibuilder, "src.main_", source.read(), "src/main_.c")