2025-04-28 18:02:15 +01:00
# libloot-python
2025-03-16 18:05:32 +00:00
2025-03-22 09:37:02 +00:00
An **experimental** Python wrapper around the libloot Rust implementation, built using [PyO3 ](https://pyo3.rs ).
2025-03-16 18:05:32 +00:00
## Build
2025-03-26 17:56:36 +00:00
To build, first set up a Python virtual environment and install [maturin ](https://github.com/PyO3/maturin ):
2025-03-16 18:05:32 +00:00
2025-05-15 20:57:00 +01:00
```
# pipx
pipx install maturin
# uv
uv tool install maturin
```
or using pip on Windows:
2025-03-26 17:56:36 +00:00
```powershell
2025-03-16 18:05:32 +00:00
python -m venv . venv
.\. venv \ Scripts \ activate
pip install maturin
2025-03-26 17:56:36 +00:00
```
2025-05-15 20:57:00 +01:00
or using pip on Linux:
2025-03-26 17:56:36 +00:00
```sh
python -m venv .venv
. .venv/bin/activate
pip install maturin
```
Then build the library in the virtual environment:
```
2025-03-16 18:05:32 +00:00
maturin develop
```
2025-03-26 17:56:36 +00:00
The library can then be imported in Python:
2025-03-16 18:05:32 +00:00
```
2025-03-26 17:56:36 +00:00
python
2025-03-16 18:05:32 +00:00
> import loot
```
2025-03-17 21:21:51 +00:00
## Usage notes
- The Python exceptions that errors are mapped to are not the same as in the Rust or C++ interfaces:
2025-05-16 17:16:58 +01:00
- The API provides the custom `CyclicInteractionError` , `UndefinedGroupError` , `PluginNotLoadedError` exception types.
2025-03-17 21:21:51 +00:00
- All other errors are raised as `ValueError` exceptions.
2025-03-22 09:37:02 +00:00
- The `LogLevel` enum and `set_logging_callback()` and `set_log_level()` functions are not exposed because the logging is integrated with Python's `logging` module instead.