How to use the cffi.recompiler function in cffi

To help you get started, we’ve selected a few cffi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_recompiler.py View on Github external
def verify(ffi, module_name, source, *args, **kwds):
    no_cpp = kwds.pop('no_cpp', False)
    kwds.setdefault('undef_macros', ['NDEBUG'])
    module_name = '_CFFI_' + module_name
    ffi.set_source(module_name, source)
    if not os.environ.get('NO_CPP') and not no_cpp:   # test the .cpp mode too
        kwds.setdefault('source_extension', '.cpp')
        source = 'extern "C" {\n%s\n}' % (source,)
    elif sys.platform != 'win32':
        # add '-Werror' to the existing 'extra_compile_args' flags
        kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
                                      ['-Werror'])
    return recompiler._verify(ffi, module_name, source, *args, **kwds)
github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_verify1.py View on Github external
def verify(self, preamble='', *args, **kwds):
        # HACK to reuse the tests from ../cffi0/test_verify.py
        FFI._verify_counter += 1
        module_name = 'verify%d' % FFI._verify_counter
        try:
            del self._assigned_source
        except AttributeError:
            pass
        self.set_source(module_name, preamble)
        return recompiler._verify(self, module_name, preamble, *args,
                                  extra_compile_args=self._extra_compile_args,
                                  **kwds)
github getsentry / milksnake / milksnake / setuptools_ext.py View on Github external
def build_cffi(base_path, **extra):
            # dylib
            dylib = self.dylib()
            if callable(dylib):
                dylib = dylib()
            log.info('copying dylib %s', os.path.basename(dylib))
            shutil.copy2(dylib, os.path.join(base_path, self.lib_filename))

            # generate cffi module
            ffi = make_ffi()
            log.info('generating cffi module for %r' % self.module_path)
            py_file = os.path.join(
                base_path, self.cffi_module_path.split('.')[-1]) + '.py'
            updated = cffi_recompiler.make_py_source(
                ffi, self.cffi_module_path, py_file)
            if not updated:
                log.info('already up-to-date')

            # wrapper
            log.info('generating wrapper for %r' % self.module_path)
            with open(os.path.join(base_path, self.name + '.py'), 'wb') as f:
                f.write((MODULE_PY % {
                    'cffi_module_path': self.cffi_module_path,
                    'lib_filename': self.lib_filename,
                    'rtld_flags': self.rtld_flags,
                }).encode('utf-8'))
        self.spec.add_build_func(build_cffi, module_base=self.module_base)
github aws-quickstart / quickstart-git2s3 / functions / source / GitPullS3 / cffi / setuptools_ext.py View on Github external
def generate_mod(py_file):
        log.info("generating cffi module %r" % py_file)
        mkpath(os.path.dirname(py_file))
        updated = recompiler.make_py_source(ffi, module_name, py_file)
        if not updated:
            log.info("already up-to-date")
github microsoft / PTVS / Python / Product / Miniconda / Miniconda3-x64 / Lib / site-packages / cffi / setuptools_ext.py View on Github external
def generate_mod(py_file):
        log.info("generating cffi module %r" % py_file)
        mkpath(os.path.dirname(py_file))
        updated = recompiler.make_py_source(ffi, module_name, py_file)
        if not updated:
            log.info("already up-to-date")
github cloudera / hue / desktop / core / ext-py / cffi-1.11.5 / cffi / setuptools_ext.py View on Github external
def generate_mod(py_file):
        log.info("generating cffi module %r" % py_file)
        mkpath(os.path.dirname(py_file))
        updated = recompiler.make_py_source(ffi, module_name, py_file)
        if not updated:
            log.info("already up-to-date")