def load_extension_module(space, path, name): if os.sep not in path: path = os.curdir + os.sep + path # force a '/' in the path state = space.fromcache(State) if state.find_extension(name, path) is not None: return old_context = state.package_context state.package_context = name, path try: from pypy.rlib import rdynload try: ll_libname = rffi.str2charp(path) try: dll = rdynload.dlopen(ll_libname) finally: lltype.free(ll_libname, flavor='raw') except rdynload.DLOpenError, e: raise operationerrfmt( space.w_ImportError, "unable to load extension module '%s': %s", path, e.msg) try: initptr = rdynload.dlsym(dll, 'init%s' % (name.split('.')[-1],)) except KeyError: raise operationerrfmt( space.w_ImportError, "function init%s not found in library %s", name, path) initfunc = rffi.cast(initfunctype, initptr) generic_cpy_call(space, initfunc) state.check_and_raise_exception()
def load_extension_module(space, path, name): if os.sep not in path: path = os.curdir + os.sep + path # force a '/' in the path state = space.fromcache(State) if state.find_extension(name, path) is not None: return old_context = state.package_context state.package_context = name, path try: from pypy.rlib import rdynload try: ll_libname = rffi.str2charp(path) try: dll = rdynload.dlopen(ll_libname) finally: lltype.free(ll_libname, flavor='raw') except rdynload.DLOpenError, e: raise operationerrfmt(space.w_ImportError, "unable to load extension module '%s': %s", path, e.msg) try: initptr = rdynload.dlsym(dll, 'init%s' % (name.split('.')[-1], )) except KeyError: raise operationerrfmt(space.w_ImportError, "function init%s not found in library %s", name, path) initfunc = rffi.cast(initfunctype, initptr) generic_cpy_call(space, initfunc) state.check_and_raise_exception()
def __init__(self, libname, mode=-1): """Load the library, or raises DLOpenError.""" self.lib = rffi.cast(DLLHANDLE, 0) with rffi.scoped_str2charp(libname) as ll_libname: self.lib = dlopen(ll_libname, mode)
def __init__(self, libname): """Load the library, or raises DLOpenError.""" RawCDLL.__init__(self, rffi.cast(DLLHANDLE, -1)) with rffi.scoped_str2charp(libname) as ll_libname: self.lib = dlopen(ll_libname)
rootlibpath = [] def identify(): return 'CINT' ts_reflect = False ts_call = False ts_memory = 'auto' ts_helper = 'auto' # force loading in global mode of core libraries, rather than linking with # them as PyPy uses various version of dlopen in various places; note that # this isn't going to fly on Windows (note that locking them in objects and # calling dlclose in __del__ seems to come too late, so this'll do for now) with rffi.scoped_str2charp('libCint.so') as ll_libname: _cintdll = rdynload.dlopen(ll_libname, rdynload.RTLD_GLOBAL | rdynload.RTLD_NOW) with rffi.scoped_str2charp('libCore.so') as ll_libname: _coredll = rdynload.dlopen(ll_libname, rdynload.RTLD_GLOBAL | rdynload.RTLD_NOW) eci = ExternalCompilationInfo( separate_module_files=[srcpath.join("cintcwrapper.cxx")], include_dirs=[incpath] + rootincpath, includes=["cintcwrapper.h"], library_dirs=rootlibpath, link_extra=["-lCore", "-lCint"], use_cpp_linker=True, ) _c_load_dictionary = rffi.llexternal( "cppyy_load_dictionary", [rffi.CCHARP], rdynload.DLLHANDLE,