當前位置: 首頁>>代碼示例>>Python>>正文


Python _cffi_backend.load_library方法代碼示例

本文整理匯總了Python中_cffi_backend.load_library方法的典型用法代碼示例。如果您正苦於以下問題:Python _cffi_backend.load_library方法的具體用法?Python _cffi_backend.load_library怎麽用?Python _cffi_backend.load_library使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在_cffi_backend的用法示例。


在下文中一共展示了_cffi_backend.load_library方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _load_backend_lib

# 需要導入模塊: import _cffi_backend [as 別名]
# 或者: from _cffi_backend import load_library [as 別名]
def _load_backend_lib(backend, name, flags):
    import os
    if name is None:
        if sys.platform != "win32":
            return backend.load_library(None, flags)
        name = "c"    # Windows: load_library(None) fails, but this works
                      # on Python 2 (backward compatibility hack only)
    first_error = None
    if '.' in name or '/' in name or os.sep in name:
        try:
            return backend.load_library(name, flags)
        except OSError as e:
            first_error = e
    import ctypes.util
    path = ctypes.util.find_library(name)
    if path is None:
        if name == "c" and sys.platform == "win32" and sys.version_info >= (3,):
            raise OSError("dlopen(None) cannot work on Windows for Python 3 "
                          "(see http://bugs.python.org/issue23606)")
        msg = ("ctypes.util.find_library() did not manage "
               "to locate a library called %r" % (name,))
        if first_error is not None:
            msg = "%s.  Additionally, %s" % (first_error, msg)
        raise OSError(msg)
    return backend.load_library(path, flags) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:27,代碼來源:api.py

示例2: _load_backend_lib

# 需要導入模塊: import _cffi_backend [as 別名]
# 或者: from _cffi_backend import load_library [as 別名]
def _load_backend_lib(backend, name, flags):
    if name is None:
        if sys.platform != "win32":
            return backend.load_library(None, flags)
        name = "c"    # Windows: load_library(None) fails, but this works
                      # (backward compatibility hack only)
    try:
        if '.' not in name and '/' not in name:
            raise OSError("library not found: %r" % (name,))
        return backend.load_library(name, flags)
    except OSError:
        import ctypes.util
        path = ctypes.util.find_library(name)
        if path is None:
            raise     # propagate the original OSError
        return backend.load_library(path, flags) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:18,代碼來源:api.py

示例3: _load_backend_lib

# 需要導入模塊: import _cffi_backend [as 別名]
# 或者: from _cffi_backend import load_library [as 別名]
def _load_backend_lib(backend, name, flags):
    import os
    if not isinstance(name, basestring):
        if sys.platform != "win32" or name is not None:
            return backend.load_library(name, flags)
        name = "c"    # Windows: load_library(None) fails, but this works
                      # on Python 2 (backward compatibility hack only)
    first_error = None
    if '.' in name or '/' in name or os.sep in name:
        try:
            return backend.load_library(name, flags)
        except OSError as e:
            first_error = e
    import ctypes.util
    path = ctypes.util.find_library(name)
    if path is None:
        if name == "c" and sys.platform == "win32" and sys.version_info >= (3,):
            raise OSError("dlopen(None) cannot work on Windows for Python 3 "
                          "(see http://bugs.python.org/issue23606)")
        msg = ("ctypes.util.find_library() did not manage "
               "to locate a library called %r" % (name,))
        if first_error is not None:
            msg = "%s.  Additionally, %s" % (first_error, msg)
        raise OSError(msg)
    return backend.load_library(path, flags) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:27,代碼來源:api.py

示例4: verify

# 需要導入模塊: import _cffi_backend [as 別名]
# 或者: from _cffi_backend import load_library [as 別名]
def verify(self, source='', tmpdir=None, **kwargs):
        """Verify that the current ffi signatures compile on this
        machine, and return a dynamic library object.  The dynamic
        library can be used to call functions and access global
        variables declared in this 'ffi'.  The library is compiled
        by the C compiler: it gives you C-level API compatibility
        (including calling macros).  This is unlike 'ffi.dlopen()',
        which requires binary compatibility in the signatures.
        """
        from .verifier import Verifier, _caller_dir_pycache
        #
        # If set_unicode(True) was called, insert the UNICODE and
        # _UNICODE macro declarations
        if self._windows_unicode:
            self._apply_windows_unicode(kwargs)
        #
        # Set the tmpdir here, and not in Verifier.__init__: it picks
        # up the caller's directory, which we want to be the caller of
        # ffi.verify(), as opposed to the caller of Veritier().
        tmpdir = tmpdir or _caller_dir_pycache()
        #
        # Make a Verifier() and use it to load the library.
        self.verifier = Verifier(self, source, tmpdir, **kwargs)
        lib = self.verifier.load_library()
        #
        # Save the loaded library for keep-alive purposes, even
        # if the caller doesn't keep it alive itself (it should).
        self._libraries.append(lib)
        return lib 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:31,代碼來源:api.py


注:本文中的_cffi_backend.load_library方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。