def find_yajl_ctypes(required):
'''
Finds and loads yajl shared object of the required major
version (1, 2, ...) using ctypes.
'''
# Importing ``ctypes`` should be in scope of this function to prevent failure
# of `backends`` package load in a runtime where ``ctypes`` is not available.
# Example of such environment is Google App Engine (GAE).
from ctypes import util, cdll
so_name = util.find_library('yajl')
if so_name is None:
raise YAJLImportError('YAJL shared object not found.')
yajl = cdll.LoadLibrary(so_name)
require_version(yajl.yajl_version(), required)
return yajl
评论列表
文章目录