Quickly and easily load shared libraries on various platforms. Also includes a libloader.com module for loading com modules on Windows.
Project description
Libloader
Libloader is a cross-platform Python library that simplifies loading shared libraries on macOS, Windows, and Linux. It handles platform-specific differences automatically, making your code more portable.
It also provides a COM module (libloader.com), making it easier to load COM DLLs on Windows.
Installation
pip install libloader
Usage
Loading Shared Libraries
from libloader import load_library
# Load a library with default paths
my_lib = load_library("mylibrary")
# Load a library with custom paths for 32-bit and 64-bit versions
my_lib = load_library("mylibrary", x86_path="./lib/x86", x64_path="./lib/x64")
# Load a library with ARM64 support (M1+ Macs, ARM servers)
my_lib = load_library("mylibrary", x64_path="./lib/x64", arm64_path="./lib/arm64")
# Call a function from the library
result = my_lib.some_function(arg1, arg2)
Working with COM Objects (Windows)
from libloader.com import load_com
# Load a COM object
excel = load_com("Excel.Application")
# Try multiple COM objects until one succeeds
speech = load_com("SAPI.SpVoice", "SpeechLib.SpVoice")
API Reference
libloader
load_library(library, x86_path=".", x64_path=".", arm64_path=None, *args, **kwargs): Load a library with the given name. Ifarm64_pathis not specified on ARM64 systems, falls back tox64_path.find_library_path(libname, x86_path=".", x64_path=".", arm64_path=None): Finds the path of the given library.get_functype(): Returns the ctypes functype for the current platform.get_library_extension(): Get the extension of the library for your current platform._do_load(file, *args, **kwargs): Attempts to actually load the library. Used internally by load_library.
libloader.com
load_com(*names): Load a COM object. If you pass multiple names, it will try each one until one works.prepare_gencache(): Prepare the gencache for COM. Called automatically by load_com().
Platform Support
Libloader automatically handles the differences between platforms:
- Windows:
.dllfiles - macOS:
.dylibfiles - Linux:
.sofiles
Architecture Support
Libloader automatically detects the system architecture and loads the appropriate library:
- x86 (32-bit): Uses
x86_path - x86_64/AMD64 (64-bit Intel/AMD): Uses
x64_path - ARM64/aarch64 (M1+ Macs, ARM servers): Uses
arm64_pathif specified, otherwise falls back tox64_path
This means existing code works on Apple Silicon Macs without modification, while allowing you to provide architecture-specific binaries when needed.
License
See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libloader-1.4.3.tar.gz.
File metadata
- Download URL: libloader-1.4.3.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c56b1ee2e866e314c35d1095d1e3b99c1c762e89a27bf26c98bd65d58f4e182
|
|
| MD5 |
d481e3134fd569204772b5ca03fb8333
|
|
| BLAKE2b-256 |
d4dd58864bd93f74cd227996cec701713e27f6a57b1c189747cfefc9c9c2e00e
|
Provenance
The following attestation bundles were made for libloader-1.4.3.tar.gz:
Publisher:
publish-to-pypi.yml on accessibleapps/libloader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libloader-1.4.3.tar.gz -
Subject digest:
9c56b1ee2e866e314c35d1095d1e3b99c1c762e89a27bf26c98bd65d58f4e182 - Sigstore transparency entry: 820642982
- Sigstore integration time:
-
Permalink:
accessibleapps/libloader@a753993f635fe355a0e98e8e4f51a357e7667a89 -
Branch / Tag:
refs/tags/v1.4.3 - Owner: https://github.com/accessibleapps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a753993f635fe355a0e98e8e4f51a357e7667a89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file libloader-1.4.3-py3-none-any.whl.
File metadata
- Download URL: libloader-1.4.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cfd541496bed79a2b5f72c316e16312ce1dd72fab6ed837801aa5e53299d6da
|
|
| MD5 |
08ce49f769775aeddd2ab3e22e835f32
|
|
| BLAKE2b-256 |
97cbdac60d530791146d52e2dab3a16531963d03899ea37eec77cc03ea8c281d
|
Provenance
The following attestation bundles were made for libloader-1.4.3-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on accessibleapps/libloader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libloader-1.4.3-py3-none-any.whl -
Subject digest:
4cfd541496bed79a2b5f72c316e16312ce1dd72fab6ed837801aa5e53299d6da - Sigstore transparency entry: 820642986
- Sigstore integration time:
-
Permalink:
accessibleapps/libloader@a753993f635fe355a0e98e8e4f51a357e7667a89 -
Branch / Tag:
refs/tags/v1.4.3 - Owner: https://github.com/accessibleapps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a753993f635fe355a0e98e8e4f51a357e7667a89 -
Trigger Event:
push
-
Statement type: