| Crates.io | pyreasonable |
| lib.rs | pyreasonable |
| version | 0.3.3-a2 |
| created_at | 2025-09-04 23:25:24.633669+00 |
| updated_at | 2025-09-10 19:25:22.470606+00 |
| description | An OWL 2 RL reasoner with reasonable performance |
| homepage | https://brickschema.org/ |
| repository | https://github.com/gtfierro/reasonable |
| max_upload_size | |
| id | 1824898 |
| size | 55,634 |
Python bindings for Reasonable — a reasonably fast OWL 2 RL reasoner implemented in Rust. This package exposes a small, typed API over rdflib terms to run materialization on RDF graphs or files.
Load from files (Turtle/N3) and materialize inferred triples:
import reasonable
r = reasonable.PyReasoner()
r.load_file("../example_models/ontologies/Brick.n3")
r.load_file("../example_models/small1.n3")
out = r.reason() # list[tuple[rdflib.term.Node, Node, Node]]
print(len(out))
Reason directly over an rdflib Graph:
import rdflib
import reasonable
from rdflib.term import URIRef
g = rdflib.Graph()
g.add((URIRef("urn:s"), URIRef("urn:p"), URIRef("urn:o")))
r = reasonable.PyReasoner()
r.from_graph(g)
triples = r.reason()
# Optionally collect into a new Graph
g_out = rdflib.Graph()
for s, p, o in triples:
g_out.add((s, p, o))
print(len(g_out))
rdflibpip install dist/reasonable-*.whlUsing uv (recommended for local dev):
cd python
# Install project dependencies (including dev tools) into a managed venv
uv sync --group dev
# Build and develop-install the extension module
uv run maturin develop -b pyo3 --release
# Sanity check
uv run python -c "import reasonable; print(reasonable.__version__)"
Without uv (system/venv):
cd python
python -m venv .venv && . .venv/bin/activate # or use your env
pip install -U maturin
maturin develop -b pyo3 --release
python -c "import reasonable; print(reasonable.__version__)"
reasonable.PyReasoner()
load_file(path: str) -> None
OSError on missing/invalid paths.from_graph(graph_or_iterable) -> None
Graph or any iterable of 3-tuples convertible to rdflib-like nodes.reason() -> list[tuple[Node, Node, Node]]
Build release wheels into dist/:
cd python
uv run maturin build --release --out dist
Install the built wheel:
pip install dist/reasonable-*.whl
pyo3/abi3-py39)rustup, cargo) for local buildsmaturin for building wheelsrdflib (runtime dependency)Run the Python test suite (uses pytest and rdflib):
cd python
uv run pytest -q
Alternatively, with a local venv:
cd python
pip install -U maturin pytest rdflib
maturin develop -b pyo3 --release
pytest -q
abi3-py39).ModuleNotFoundError: No module named 'reasonable':
maturin develop in the same environment you’re importing from.xcode-select --install.OSError when calling load_file(...):
python/tests/ minimal and representative. Prefer inputs from example_models/.cargo fmt/cargo clippy.README.md.