Python bindings for Rudof
Project description
pyrudof - Python bindings for Rudof
pyrudof provides Python bindings for rudof,
a Rust library for Semantic Web operations.
At a high level it supports:
- Loading and serializing RDF and PG data.
- Loading, checking, serializing and validating ShEx schemas.
- Loading, serializing and validating SHACL shapes.
- Loading, serializing and validating PGSchemas.
- Loading, running and serializing SPARQL queries and query results.
- Converting and comparing schemas between supported formats.
- Loading and serializing DCTAP and Service Descriptions.
- Generating synthetic data from schemas.
Installation
Install from PyPI (recommended)
pip install pyrudof
pyrudof is built with PyO3 using abi3 wheels (Python 3.7+ compatible).
Build from source
Building from source requires a working Rust toolchain and Python.
# Clone the repository
git clone https://github.com/rudof-project/rudof.git
cd rudof/python
# Optional but recommended: virtual environment
python -m venv .venv
# Linux/macOS:
source .venv/bin/activate
# Windows PowerShell:
# .\.venv\Scripts\Activate.ps1
# Build and install editable package
pip install maturin
pip install -e .
For a release wheel:
maturin build --release
pip install --force-reinstall target/wheels/pyrudof-*.whl
Architecture and package structure
Package layout
| Path | Purpose |
|---|---|
src/ |
Rust implementation of the Python bindings (Rudof, RudofConfig, generator APIs, enums, and error mappings). |
stubs/pyrudof/ |
Hand-maintained .pyi type stubs for static type checking and editor support. |
examples/ |
Runnable example scripts organized by category, plus examples.toml manifest metadata. |
tests/ |
Python unittest suite and manifest registry loader for example-based tests. |
docs/ |
Sphinx docs, including the examples page generator (generate_examples_doc.py). |
Cargo.toml / pyproject.toml |
Rust crate and Python build configuration (maturin + PyO3). |
Test architecture
Tests are dynamically generated from examples/examples.toml.
Each generated test:
- Executes the registered Python example as a subprocess.
- Asserts a zero exit code.
- Checks configured
expected_outputsubstrings (if any).
| Component | Purpose |
|---|---|
tests/test_examples.py |
Builds dynamic unittest.TestCase classes per category/example. |
tests/examples_registry.py |
Loads and validates examples/examples.toml entries. |
examples/examples.toml |
Single source of truth for metadata and category order. |
examples/**/*.py |
Executable example scripts run by tests and referenced by docs. |
Testing
All test commands are run from python/tests.
Run the full suite
cd python/tests
python -m unittest discover -vvv
Run a specific category or test
# All ShEx examples
python -m unittest test_examples.TestShexExamples -v
# All SHACL examples
python -m unittest test_examples.TestShaclExamples -v
# All data generation examples
python -m unittest test_examples.TestGenerateExamples -v
# A single example
python -m unittest test_examples.TestShexExamples.test_shex_validate_inline -v
Run skipped examples
Examples marked with skip_test = true in the manifest are skipped by default.
# Linux/macOS
RUN_SKIPPED_EXAMPLES=1 python -m unittest test_examples -v
# Windows PowerShell
$env:RUN_SKIPPED_EXAMPLES="1"; python -m unittest test_examples -v
Examples and documentation
The examples system is intentionally centralized:
examples/examples.tomlstores metadata (key,source_file,title,description,category,files,expected_output,skip_test).examples/**/*.pystores the executable code.tests/test_examples.pyanddocs/generate_examples_doc.pyboth read from that same manifest.
Available categories
| Category | Description |
|---|---|
rdf |
RDF loading, serialization, node inspection |
sparql |
SELECT / CONSTRUCT query workflows |
shex |
ShEx loading, validation, and serialization |
shacl |
SHACL loading, validation, extraction, serialization |
dctap |
DCTAP profile handling |
endpoint |
Service description examples |
generate |
Synthetic data generation APIs |
utility |
Config, resets, version, module/error helpers |
Add a new example
- Create a runnable script under
python/examples/(recommended: place it inside a category subfolder, for examplepython/examples/shex/my_example.py). - Register it in
python/examples/examples.toml. - Run tests from
python/tests. - Regenerate and check docs in
python/docs.
Manifest template:
[[example]]
key = "my_example"
source_file = "shex/my_example.py"
title = "My Example"
description = "What this example demonstrates"
category = "shex" # rdf | sparql | shex | shacl | dctap | endpoint | generate | utility
files = { data = "person.ttl" } # optional referenced files
expected_output = ["Alice"] # optional substrings (can be empty list)
# skip_test = true # optional (network/special runtime)
Build docs locally
cd python/docs
python generate_examples_doc.py --update
python generate_examples_doc.py --check
python -m sphinx -b html . _build/html
Then open python/docs/_build/html/index.html.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 pyrudof-0.2.12-cp37-abi3-win_amd64.whl.
File metadata
- Download URL: pyrudof-0.2.12-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
463231e6afe97df715d658f8f7d36af465bf7dece836c05e87bddc879b6da2ff
|
|
| MD5 |
44f4b75f86022b77cb34b901c6cbe9f2
|
|
| BLAKE2b-256 |
7804f57616862806f13acb1bb566a97dc3fa7b022984ab8f2f05febaa94a2d7d
|
File details
Details for the file pyrudof-0.2.12-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyrudof-0.2.12-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f170e5a065c0934827fb6ed0d01ad463d8f311dbefdf56d29d0295e90e1655
|
|
| MD5 |
5fe6727a76914e2798db38af25e73f83
|
|
| BLAKE2b-256 |
6c84a3669029626080f81ccab1fb2c093209d1c7a3d671bfbbbcb48c0ac71c10
|
File details
Details for the file pyrudof-0.2.12-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyrudof-0.2.12-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db54f4f3c8f73b9a9a8f1bb663a8716e4594f6dc180329579c63407b8b443925
|
|
| MD5 |
943c97b212863dca35e1174ae4eabb7b
|
|
| BLAKE2b-256 |
8a0db86d88b552eea7edcb97b45f4cbf0309e5cb4ac668237e8db81fd5a354c7
|
File details
Details for the file pyrudof-0.2.12-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyrudof-0.2.12-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.9 MB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6cad3a63c9d97e8ee610de95401edace76cddbd749fe400e792bd9cf0011407
|
|
| MD5 |
64241b339ad7e53983a2a4319b2a67e7
|
|
| BLAKE2b-256 |
197bc754eb29003577b7707b4492fcab348b8ba142aeee6300d1f7a89bb5fd32
|
File details
Details for the file pyrudof-0.2.12-cp37-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyrudof-0.2.12-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17e60cf62519f5f7e31f5226101039f950e90a25c39fe4ac8356f0a697711506
|
|
| MD5 |
9b87cfa16953d1fc59d88c0e43029b14
|
|
| BLAKE2b-256 |
6c0682b1d7ee3fe46f80a5fe0819baf7beb53ffdeac48981c5d21e612636dced
|