API Reference¶
Shared Library Manager¶
The implementation of loading for packages that contain a reusable native library.
- class shared_lib_manager.PlatformLibrary(*, Darwin=None, Linux=None, Windows=None, default=None)[source]¶
A tuple containing the paths to a library on different platforms.
- Parameters:
Linux (os.PathLike) – The path to the library on Linux.
Darwin (os.PathLike) – The path to the library on macOS.
Windows (os.PathLike) – The path to the library on Windows.
default (Callable[[], os.PathLike]) – A callable that returns the default path to the library. This is used when the current platform is not found in the library paths. It may also be used by libraries that require a more general key for determining what path to use if the choice needs to be made at runtime based on additional factors.
- class shared_lib_manager.LibraryLoader(libraries)[source]¶
Loader for a set of native libraries associated with a module.
- Parameters:
libraries (dict[str, PlatformLibrary | tuple[os.PathLike | str, os.PathLike | str, os.PathLike | str]]) – A mapping from library names to the paths of the libraries on each platform. If a tuple is passed, it must be ordered as (Linux, Darwin, Windows).
Methods
load([libraries, prefer_system])Load the native library and return the ctypes.CDLL object.
Shared Library Consumer¶
The implementation of consumer-side loading.
- shared_lib_consumer.load_library_module(module_name, *, prefer_system=False)[source]¶
Load the specified module, if it exists.
The function allows the module to not exist so that it may be used by a consumer in non-pip contexts (for example, if the library is instead installed by some other package manager and so no wheel exists).