Skip to content

Commit fa191dc

Browse files
committed
docs: Improve README with installation, usage, and API reference
1 parent bc4e343 commit fa191dc

2 files changed

Lines changed: 68 additions & 11 deletions

File tree

README.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,67 @@
11
# Libloader
22

3-
Libloader provides a way to quickly and easily load shared libraries on macOS, Windows and Linux.
3+
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.
44

5-
It also provides a COM module (libloader.com), making it easier to load COM DLLs on Windows.
5+
It also provides a COM module (`libloader.com`), making it easier to load COM DLLs on Windows.
66

7-
## Functions.
7+
## Installation
88

9-
### com
9+
```bash
10+
pip install libloader
11+
```
1012

11-
* prepare_gencache(): Prepare the gencache for COM. Not mandatory to be called by you, because load_com() calls it.
12-
* load_com(*names): Let's you load a COM object. If you pass more than one, if the first fails, it will try the next one, until one works, or it runs out of objects.
13+
## Usage
14+
15+
### Loading Shared Libraries
16+
17+
```python
18+
from libloader import load_library
19+
20+
# Load a library with default paths
21+
my_lib = load_library("mylibrary")
22+
23+
# Load a library with custom paths for 32-bit and 64-bit versions
24+
my_lib = load_library("mylibrary", x86_path="./lib/x86", x64_path="./lib/x64")
25+
26+
# Call a function from the library
27+
result = my_lib.some_function(arg1, arg2)
28+
```
29+
30+
### Working with COM Objects (Windows)
31+
32+
```python
33+
from libloader.com import load_com
34+
35+
# Load a COM object
36+
excel = load_com("Excel.Application")
37+
38+
# Try multiple COM objects until one succeeds
39+
speech = load_com("SAPI.SpVoice", "SpeechLib.SpVoice")
40+
```
41+
42+
## API Reference
1343

1444
### libloader
1545

16-
* load_library(library, x86_path=".", x64_path=".", *args, **kwargs): Load a library with the given name.
17-
* _do_load(file, *args, **kwargs): Attempts to actually load the library. Used by load_library, although you can call it yourself.
18-
* find_library_path(libname, x86_path=".", x64_path="."): Finds the path of the given library.
19-
* get_functype(): Returns the ctypes functype of the given platform.
20-
* get_library_extension(): Get the extension of the library for your current platform.
46+
* `load_library(library, x86_path=".", x64_path=".", *args, **kwargs)`: Load a library with the given name.
47+
* `find_library_path(libname, x86_path=".", x64_path=".")`: Finds the path of the given library.
48+
* `get_functype()`: Returns the ctypes functype for the current platform.
49+
* `get_library_extension()`: Get the extension of the library for your current platform.
50+
* `_do_load(file, *args, **kwargs)`: Attempts to actually load the library. Used internally by load_library.
51+
52+
### libloader.com
53+
54+
* `load_com(*names)`: Load a COM object. If you pass multiple names, it will try each one until one works.
55+
* `prepare_gencache()`: Prepare the gencache for COM. Called automatically by load_com().
56+
57+
## Platform Support
58+
59+
Libloader automatically handles the differences between platforms:
60+
61+
* Windows: `.dll` files
62+
* macOS: `.dylib` files
63+
* Linux: `.so` files
64+
65+
## License
66+
67+
See the LICENSE file for details.

setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
from setuptools import find_packages, setup
2+
import os
23

34
from libloader import __author__, __author_email__, __doc__, __version__
45

6+
# Read the long description from README.md
7+
with open("README.md", "r", encoding="utf-8") as fh:
8+
long_description = fh.read()
9+
510
setup(
611
name="libloader",
712
version=__version__,
813
author=__author__,
914
author_email=__author_email__,
1015
description=__doc__,
16+
long_description=long_description,
17+
long_description_content_type="text/markdown",
1118
packages=find_packages(),
1219
zip_safe=False,
1320
classifiers=[
1421
"Development Status :: 3 - Alpha",
1522
"Intended Audience :: Developers",
1623
"Programming Language :: Python",
1724
"Topic :: Software Development :: Libraries",
25+
"Operating System :: OS Independent",
26+
"License :: OSI Approved :: MIT License",
1827
],
28+
python_requires=">=3.6",
1929
)

0 commit comments

Comments
 (0)