Python ctypes 模块,RTLD_GLOBAL 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用ctypes.RTLD_GLOBAL

项目:gil_load    作者:chrisjbillington    | 项目源码 | 文件源码
def _load_preload_lib():
    """profiling won't work if the library isn't preloaded using LD_PRELOAD,
    but we ensure it's loaded anyway so that we can import the cython
    extension and call its functions still - otherwise it won't import since
    it has not been linked to the preload library."""
    import os
    import ctypes
    from distutils.sysconfig import get_config_var
    this_dir = os.path.dirname(os.path.realpath(__file__))
    so_name = os.path.join(this_dir, 'preload')
    ext_suffix = get_config_var('EXT_SUFFIX')
    if ext_suffix is not None:
        so_name += ext_suffix
    else:
        so_name += '.so'
    import sys
    ctypes.CDLL(so_name, ctypes.RTLD_GLOBAL) 
    return so_name
项目:zeronet-debian    作者:bashrc    | 项目源码 | 文件源码
def openLibrary():
    import ctypes
    import ctypes.util
    try:
        if sys.platform.startswith("win"):
            dll_path = "src/lib/opensslVerify/libeay32.dll"
        elif sys.platform == "cygwin":
            dll_path = "/bin/cygcrypto-1.0.0.dll"
        else:
            dll_path = "/usr/local/ssl/lib/libcrypto.so"
        ssl = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL)
        assert ssl
    except:
        dll_path = ctypes.util.find_library('ssl') or ctypes.util.find_library('crypto') or ctypes.util.find_library('libcrypto')
        ssl = ctypes.CDLL(dll_path or 'libeay32', ctypes.RTLD_GLOBAL)
    return ssl
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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
项目:SwiftKitten    作者:johncsnyder    | 项目源码 | 文件源码
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
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
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
项目:git_intgrtn_aws_s3    作者:droidlabour    | 项目源码 | 文件源码
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
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
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
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
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
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
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
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
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
项目:MatchingMarkets.py    作者:QuantEcon    | 项目源码 | 文件源码
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
项目:bawk    作者:jttwnsnd    | 项目源码 | 文件源码
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
项目:Aurora    作者:upul    | 项目源码 | 文件源码
def _load_lib():
    """Load libary in build/lib."""
    lib_root = Path(__file__).parents[2]
    lib_path = os.path.join(lib_root, 'cuda/build/lib/')
    path_to_so_file = os.path.join(lib_path, "libc_runtime_api.so")
    lib = ctypes.CDLL(path_to_so_file, ctypes.RTLD_GLOBAL)
    return lib


# global library instance
项目:aws-lambda-python-codecommit-s3-deliver    作者:0xlen    | 项目源码 | 文件源码
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
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
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
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
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
项目:fython    作者:nicolasessisbreton    | 项目源码 | 文件源码
def use_mkl():
    set_compiler(
        cmd = 'ifort',
        prefix = '',
        infix = '_mp_',
        suffix = '_',
        debug = """
            -g 
            -traceback
            -gen-interfaces 
            -warn all
            -check all
            -fpe0
            -ftrapuv
            -I/opt/intel/mkl/include
        """,
        release = """
            -fast
            -I/opt/intel/mkl/include
        """,
        link = """
            -L/opt/intel/mkl/lib/intel64 
            -lmkl_intel_lp64 
            -lmkl_core
            -lmkl_sequential 
            -lpthread 
            -lm
        """,
        error_regex = '(error #|ld:)',

        warning_regex = '(warning #|remark #)',
    )


    # needed to load mkl
    # see: https://answers.launchpad.net/dolfin/+question/205219
    import ctypes
    ctypes.CDLL('libmkl_rt.so', ctypes.RTLD_GLOBAL)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
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
项目:slack_scholar    作者:xLeitix    | 项目源码 | 文件源码
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
项目:ropi    作者:ThumbGen    | 项目源码 | 文件源码
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
项目:RemoteTree    作者:deNULL    | 项目源码 | 文件源码
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
项目:quickstart-git2s3    作者:aws-quickstart    | 项目源码 | 文件源码
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
项目:quickstart-git2s3    作者:aws-quickstart    | 项目源码 | 文件源码
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
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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
项目:PyQYT    作者:collinsctk    | 项目源码 | 文件源码
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
项目:glustertool    作者:gluster    | 项目源码 | 文件源码
def _lazy_init_libgfapi():
    """
    Loads ctypes library only if not loaded already
    """
    global _api
    if not _api:
        _api = ctypes.CDLL(find_library("gfapi"), ctypes.RTLD_GLOBAL)
项目:cwrap    作者:Statoil    | 项目源码 | 文件源码
def load( lib, so_version = None, path = None, so_ext = None):
    """Thin wrapper around the ctypes.CDLL function for loading shared
    library.

    If the path argument is non Null the function will first try to
    load with full path. If that fails it wil also try to load without
    a path component, invoking normal dlopen() semantics.
    """

    dll = None
    lib_files = [ lib_name( lib, path = None, so_version = so_version ),
                  lib_name( lib, path = None, so_version = so_version, so_ext = so_ext ),
                  lib_name( lib, path = path, so_version = so_version ),
                  lib_name( lib, path = path, so_version = so_version, so_ext = so_ext )
                ]

    for lib_file in lib_files:
        try:
            dll = ctypes.CDLL(lib_file , ctypes.RTLD_GLOBAL)
            return dll
        except Exception as exc:
            error = exc

    error_msg = "\nFailed to load shared library:%s\n\ndlopen() error: %s\n" % (lib , error)

    LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH")
    if not LD_LIBRARY_PATH:
        LD_LIBRARY_PATH = ""

    error_msg += """
The runtime linker has searched through the default location of shared
libraries, and also the locations mentioned in your LD_LIBRARY_PATH
variable. Your current LD_LIBRARY_PATH setting is:

   LD_LIBRARY_PATH: %s

You might need to update this variable?
""" % LD_LIBRARY_PATH
    raise ImportError(error_msg)
项目:fython    作者:nicolasessisbreton    | 项目源码 | 文件源码
def use_mkl_blas_lapack():
    set_compiler(
        cmd = 'ifort',
        prefix = '',
        infix = '_mp_',
        suffix = '_',
        debug = """
            -g 
            -traceback
            -gen-interfaces 
            -warn all
            -check all
            -fpe0
            -ftrapuv
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        release = """
            -fast
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        link = """
            /opt/intel/mkl/lib/intel64/libmkl_blas95_lp64.a
            /opt/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a
            -L/opt/intel/mkl/lib/intel64
            -lmkl_intel_lp64
            -lmkl_core
            -lmkl_intel_thread
            -lpthread
            -lm
            -ldl    
        """,
        error_regex = '(error #|ld:)',

        warning_regex = '(warning #|remark #)',
    )


    # needed to load mkl
    # see: https://answers.launchpad.net/dolfin/+question/205219
    import ctypes
    ctypes.CDLL('libmkl_rt.so', ctypes.RTLD_GLOBAL)
    ctypes.CDLL('/opt/intel/lib/intel64/libiomp5.so', ctypes.RTLD_GLOBAL)
项目:fython    作者:nicolasessisbreton    | 项目源码 | 文件源码
def use_mkl_blas_lapack_gurobi():
    set_compiler(
        cmd = 'ifort',
        prefix = '',
        infix = '_mp_',
        suffix = '_',
        debug = """
            -g 
            -traceback
            -gen-interfaces 
            -warn all
            -check all
            -fpe0
            -ftrapuv
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        release = """
            -fast
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        link = """
            /opt/intel/mkl/lib/intel64/libmkl_blas95_lp64.a
            /opt/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a
            -L/opt/intel/mkl/lib/intel64
            -L/opt/gurobi751/linux64/lib
            -lgurobi75
            -lmkl_intel_lp64
            -lmkl_core
            -lmkl_intel_thread
            -lpthread
            -lm
            -ldl    
        """,
        error_regex = '(error #|ld:)',

        warning_regex = '(warning #|remark #)',
    )


    # needed to load mkl
    # see: https://answers.launchpad.net/dolfin/+question/205219
    import ctypes
    ctypes.CDLL('libmkl_rt.so', ctypes.RTLD_GLOBAL)
    ctypes.CDLL('/opt/intel/lib/intel64/libiomp5.so', ctypes.RTLD_GLOBAL)
项目:fython    作者:nicolasessisbreton    | 项目源码 | 文件源码
def use_mkl_gurobi():
    set_compiler(
        cmd = 'ifort',
        prefix = '',
        infix = '_mp_',
        suffix = '_',
        debug = """
            -g 
            -traceback
            -gen-interfaces 
            -warn all
            -check all
            -fpe0
            -ftrapuv
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        release = """
            -fast
            -qopenmp
            -I/opt/intel/mkl/include/intel64/lp64
            -I/opt/intel/mkl/include
        """,
        link = """
            -L/opt/intel/mkl/lib/intel64
            -L/opt/gurobi751/linux64/lib
            -lgurobi75
            -lmkl_intel_lp64
            -lmkl_core
            -lmkl_intel_thread
            -lpthread
            -lm
            -ldl    
        """,
        error_regex = '(error #|ld:)',

        warning_regex = '(warning #|remark #)',
    )


    # needed to load mkl
    # see: https://answers.launchpad.net/dolfin/+question/205219
    import ctypes
    ctypes.CDLL('libmkl_rt.so', ctypes.RTLD_GLOBAL)
    ctypes.CDLL('/opt/intel/lib/intel64/libiomp5.so', ctypes.RTLD_GLOBAL)