本文整理汇总了Python中cffi.verifier.Verifier类的典型用法代码示例。如果您正苦于以下问题:Python Verifier类的具体用法?Python Verifier怎么用?Python Verifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Verifier类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_library
def test_load_library(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!3*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
library = v.load_library()
assert library.sin(12.3) == math.sin(12.3)
示例2: test_name_from_checksum_of_csrc
def test_name_from_checksum_of_csrc(self):
names = []
for csrc in ['123', '123', '1234']:
ffi = FFI()
ffi.cdef("double sin(double x);")
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
names.append(v.get_module_name())
assert names[0] == names[1] != names[2]
示例3: test_extension_forces_write_source
def test_extension_forces_write_source(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there9!%s*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
assert not os.path.exists(v.sourcefilename)
v.get_extension()
assert os.path.exists(v.sourcefilename)
示例4: finalize_options
def finalize_options(self):
from cffi.verifier import Verifier
import _libpassacre
verifier = Verifier(
_libpassacre.ffi, _libpassacre.preamble, modulename='_libpassacre_c',
include_dirs=[libpassacre_build_dir],
extra_objects=[os.path.join(libpassacre_build_dir, 'libpassacre.a')])
self.distribution.ext_modules = [verifier.get_extension()]
_build.finalize_options(self)
示例5: test_name_from_checksum_of_cdef
def test_name_from_checksum_of_cdef(self):
names = []
for csrc in ['double', 'double', 'float']:
ffi = FFI()
ffi.cdef("%s sin(double x);" % csrc)
v = Verifier(ffi, "#include <math.h>",
force_generic_engine=self.generic)
names.append(v.get_module_name())
assert names[0] == names[1] != names[2]
示例6: test_write_source
def test_write_source(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
v.write_source()
with open(v.sourcefilename, 'r') as f:
data = f.read()
assert csrc in data
示例7: test_verifier_args
def test_verifier_args(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!4*/#include "test_verifier_args.h"\n' % self
udir.join('test_verifier_args.h').write('#include <math.h>\n')
v = Verifier(ffi, csrc, include_dirs=[str(udir)],
force_generic_engine=self.generic)
library = v.load_library()
assert library.sin(12.3) == math.sin(12.3)
示例8: test_write_source_explicit_filename
def test_write_source_explicit_filename(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic,
libraries=[self.lib_m])
v.sourcefilename = filename = str(udir.join('write_source.c'))
v.write_source()
assert filename == v.sourcefilename
with open(filename, 'r') as f:
data = f.read()
assert csrc in data
示例9: test_write_source_to_file_obj
def test_write_source_to_file_obj(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
f = StringIO()
v.write_source(file=f)
assert csrc in f.getvalue()
示例10: test_compile_module
def test_compile_module(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
v.compile_module()
assert v.get_module_name().startswith('_cffi_')
if v.generates_python_module():
mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
assert hasattr(mod, '_cffi_setup')
示例11: test_compile_module_explicit_filename
def test_compile_module_explicit_filename(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!2*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
basename = self.__class__.__name__ + 'test_compile_module'
v.modulefilename = filename = str(udir.join(basename + '.so'))
v.compile_module()
assert filename == v.modulefilename
assert v.get_module_name() == basename
if v.generates_python_module():
mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
assert hasattr(mod, '_cffi_setup')
示例12: open
with open(os.path.join(__dir__, 'cffi_template.py'), 'rb') as cffi_template:
uvcffi_code = cffi_template.read().decode('utf-8').format(**locals())
with open(os.path.join(__dir__, 'uvcffi', '__init__.py'), 'wb') as uvcffi_module:
uvcffi_module.write(uvcffi_code.encode('utf-8'))
ffi = cffi.FFI()
ffi.cdef(declarations)
try:
ffi.set_source('_uvcffi', source)
extension = ffi.distutils_extension()
except AttributeError:
from cffi.verifier import Verifier
verifier = Verifier(ffi, source, modulename='_uvcffi')
extension = verifier.get_extension()
def choose_path(paths):
for path in paths:
if os.path.exists(path):
return path
def win32_find_python27():
assert sys.platform == 'win32'
python27 = None
if sys.version_info[:2] == (2, 7):
return sys.executable
if 'PYTHON' in os.environ and os.environ['PYTHON'].endswith('.exe'):