Skip to content

Commit

Permalink
DOC: first attempt at documenting load_library.
Browse files Browse the repository at this point in the history
Found some doco at
http://docs.scipy.org/doc/numpy-dev/user/c-info.python-as-glue.html
which seemed to describe the function, so used that.
  • Loading branch information
pizzathief committed Sep 12, 2015
1 parent c4924a7 commit 02ed190
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions numpy/ctypeslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,33 @@ def _dummy(*args, **kwds):

# Adapted from Albert Strasheim
def load_library(libname, loader_path):
"""
It is possible to load a library using
>>> lib = ctypes.cdll[<full_path_name>]
But there are cross-platform considerations, such as library file extensions,
plus the fact Windows will just load the first library it finds with that name.
Numpy supplies the load_library function as a convenience.
Parameters
----------
libname : string
Name of the library, which can have 'lib' as a prefix,
but without an extension.
loader_path : string
Where the library can be found.
Returns
-------
ctypes.cdll[libpath] : library object
A ctypes library object
Raises
------
OSError
If there is no library with the expected extension, or the
library is defective and can't be loaded.
"""
if ctypes.__version__ < '1.0.1':
import warnings
warnings.warn("All features of ctypes interface may not work " \
Expand Down

0 comments on commit 02ed190

Please sign in to comment.