本文整理汇总了Python中ctypes.RTLD_GLOBAL属性的典型用法代码示例。如果您正苦于以下问题:Python ctypes.RTLD_GLOBAL属性的具体用法?Python ctypes.RTLD_GLOBAL怎么用?Python ctypes.RTLD_GLOBAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ctypes
的用法示例。
在下文中一共展示了ctypes.RTLD_GLOBAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_jl_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def get_jl_lib(conf) -> JuliaPreLoad:
jl = conf["julia"]
lib_path = jl["lib"]
sys_image = jl["image"]
binary = jl["bin"]
lib = ctypes.PyDLL(lib_path, ctypes.RTLD_GLOBAL)
lib.jl_eval_string.argtypes = [ctypes.c_char_p]
lib.jl_eval_string.restype = ctypes.c_void_p
try:
init = lib.jl_init_with_image
except AttributeError:
init = lib.jl_init_with_image__threading
return JuliaPreLoad(
lambda: init(binary.encode(), sys_image.encode()), lib)
示例2: _server_env
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _server_env(load_library):
"""Server environment function return temp dir"""
temp = util.tempdir()
# pylint: disable=unused-variable
@register_func("tvm.rpc.server.workpath")
def get_workpath(path):
return temp.relpath(path)
@register_func("tvm.rpc.server.load_module", override=True)
def load_module(file_name):
"""Load module from remote side."""
path = temp.relpath(file_name)
m = _load_module(path)
logger.info("load_module %s", path)
return m
libs = []
load_library = load_library.split(":") if load_library else []
for file_name in load_library:
file_name = find_lib_path(file_name)[0]
libs.append(ctypes.CDLL(file_name, ctypes.RTLD_GLOBAL))
logger.info("Load additional library %s", file_name)
temp.libs = libs
return temp
示例3: import_ctypes_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def import_ctypes_lib(route, libname):
lib_path = route + libname
if platform.system() == 'Darwin':
ext = '.dylib'
elif platform.system() == 'Linux':
ext = '.so'
else:
raise NotImplementedError('The platform ' + platform.system() + 'is not supported')
lib_path += ext
lib_path = os.path.abspath(lib_path)
try:
library = ct.CDLL(lib_path, mode=ct.RTLD_GLOBAL)
except:
import traceback
import sys
traceback.print_exc(file=sys.stderr)
sys.exit(1)
return library
示例4: COINMP_DLL_load_dll
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def COINMP_DLL_load_dll(path):
"""
function that loads the DLL useful for debugging installation problems
"""
import ctypes
if os.name == 'nt':
lib = ctypes.windll.LoadLibrary(str(path[-1]))
else:
# linux hack to get working
mode = ctypes.RTLD_GLOBAL
for libpath in path[:-1]:
# RTLD_LAZY = 0x00001
ctypes.CDLL(libpath, mode=mode)
lib = ctypes.CDLL(path[-1], mode=mode)
return lib
示例5: libgl_workaround
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def libgl_workaround() -> None:
"""Work around QOpenGLShaderProgram issues, especially for Nvidia.
See https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826
"""
if os.environ.get('QUTE_SKIP_LIBGL_WORKAROUND'):
return
libgl = ctypes.util.find_library("GL")
if libgl is not None: # pragma: no branch
ctypes.CDLL(libgl, mode=ctypes.RTLD_GLOBAL)
示例6: COINMP_DLL_load_dll
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def COINMP_DLL_load_dll(path):
"""
function that loads the DLL useful for debugging installation problems
"""
import ctypes
if os.name == 'nt':
lib = ctypes.windll.LoadLibrary(str(path[-1]))
else:
#linux hack to get working
mode = ctypes.RTLD_GLOBAL
for libpath in path[:-1]:
#RTLD_LAZY = 0x00001
ctypes.CDLL(libpath, mode = mode)
lib = ctypes.CDLL(path[-1], mode = mode)
return lib
示例7: _load_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _load_lib():
"""Load libary by searching possible path."""
lib_path = libinfo.find_lib_path()
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
# DMatrix functions
lib.DGLGetLastError.restype = ctypes.c_char_p
return lib, os.path.basename(lib_path[0])
# version number
示例8: load
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def load(self,path):
"""Given a path to a library, load it."""
try:
# Darwin requires dlopen to be called with mode RTLD_GLOBAL instead
# of the default RTLD_LOCAL. Without this, you end up with
# libraries not being loadable, resulting in "Symbol not found"
# errors
if sys.platform == 'darwin':
return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
else:
return ctypes.cdll.LoadLibrary(path)
except OSError as e:
raise ImportError(e)
示例9: _load_libzmq
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _load_libzmq():
"""load bundled libzmq if there is one"""
import sys, ctypes, platform, os
dlopen = hasattr(sys, 'getdlopenflags') # unix-only
# RTLD flags are added to os in Python 3
# get values from os because ctypes values are WRONG on pypy
PYPY = platform.python_implementation().lower() == 'pypy'
if dlopen:
dlflags = sys.getdlopenflags()
# set RTLD_GLOBAL, unset RTLD_LOCAL
flags = ctypes.RTLD_GLOBAL | dlflags
# ctypes.RTLD_LOCAL is 0 on pypy, which is *wrong*
flags &= ~ getattr(os, 'RTLD_LOCAL', 4)
# pypy on darwin needs RTLD_LAZY for some reason
if PYPY and sys.platform == 'darwin':
flags |= getattr(os, 'RTLD_LAZY', 1)
flags &= ~ getattr(os, 'RTLD_NOW', 2)
sys.setdlopenflags(flags)
try:
from . import libzmq
except ImportError:
pass
else:
# store libzmq as zmq._libzmq for backward-compat
globals()['_libzmq'] = libzmq
if PYPY:
# some versions of pypy (5.3 < ? < 5.8) needs explicit CDLL load for some reason,
# otherwise symbols won't be globally available
# do this unconditionally because it should be harmless (?)
ctypes.CDLL(libzmq.__file__, ctypes.RTLD_GLOBAL)
finally:
if dlopen:
sys.setdlopenflags(dlflags)
示例10: __init__
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def __init__(self):
self.RTLD_LAZY = 0 # not supported anyway by ctypes
self.RTLD_NOW = 0
self.RTLD_GLOBAL = ctypes.RTLD_GLOBAL
self.RTLD_LOCAL = ctypes.RTLD_LOCAL
示例11: _load_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _load_lib():
"""Load libary by searching possible path."""
lib_path = libinfo.find_lib_path()
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
# DMatrix functions
lib.TVMGetLastError.restype = ctypes.c_char_p
return lib, os.path.basename(lib_path[0])
# version number
示例12: _load_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _load_lib():
"""Load local library, assuming they are simulator."""
lib_path = find_libvta(optional=True)
if not lib_path:
return []
try:
return [ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)]
except OSError:
return []
示例13: _load_lib
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def _load_lib():
"""Load libary by searching possible path."""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
lib_search = curr_path
lib_path = libinfo.find_lib_path(_get_lib_names(), lib_search, optional=True)
if lib_path is None:
return None, None
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
return lib, os.path.basename(lib_path[0])
示例14: load
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def load(self,path):
"""Given a path to a library, load it."""
try:
# Darwin requires dlopen to be called with mode RTLD_GLOBAL instead
# of the default RTLD_LOCAL. Without this, you end up with
# libraries not being loadable, resulting in "Symbol not found"
# errors
if sys.platform == 'darwin':
return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
else:
return ctypes.cdll.LoadLibrary(path)
except OSError,e:
raise ImportError(e)
示例15: get_cudaFindKnnSetGPU
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import RTLD_GLOBAL [as 别名]
def get_cudaFindKnnSetGPU():
dll = ctypes.CDLL('./gpuKnnLibrary.so', mode=ctypes.RTLD_GLOBAL)
func = dll.cudaFindKnnSetGPU
func.argtypes = [POINTER(c_int32), POINTER(c_float), POINTER(c_float), POINTER(c_float), c_int, c_int, c_int, c_int, c_int, c_int]
return func
# create __cudaFindKnnSetGPU function with get_cudaFindKnnSetGPU()