Skip to main content

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:

  1. Executes the registered Python example as a subprocess.
  2. Asserts a zero exit code.
  3. Checks configured expected_output substrings (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.toml stores metadata (key, source_file, title, description, category, files, expected_output, skip_test).
  • examples/**/*.py stores the executable code.
  • tests/test_examples.py and docs/generate_examples_doc.py both 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

  1. Create a runnable script under python/examples/ (recommended: place it inside a category subfolder, for example python/examples/shex/my_example.py).
  2. Register it in python/examples/examples.toml.
  3. Run tests from python/tests.
  4. 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyrudof-0.2.20-cp37-abi3-win_amd64.whl (9.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

pyrudof-0.2.20-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

pyrudof-0.2.20-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

pyrudof-0.2.20-cp37-abi3-macosx_11_0_arm64.whl (10.0 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

pyrudof-0.2.20-cp37-abi3-macosx_10_12_x86_64.whl (10.4 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file pyrudof-0.2.20-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: pyrudof-0.2.20-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 9.6 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.2

File hashes

Hashes for pyrudof-0.2.20-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fbe36e5d9294c7b2186038828d798d26a54d00c87f520dc6537fec49cc8b41f8
MD5 50abf0b33c7fc132e95cf4c11f56a985
BLAKE2b-256 4904d13c56f1f80431f0986f90811552b98cfa459421341dec5b83112c2e7fa1

See more details on using hashes here.

File details

Details for the file pyrudof-0.2.20-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrudof-0.2.20-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cff9913f9785ce85c6a6d8f564a8237728fcf24e1931d05e25f22e159ebf0bc4
MD5 81640d5a0e9e7af40ec7a8b705b40a23
BLAKE2b-256 7987b7da52b70a9287f3f13165561737a5088b5d749fde0ca157b5ca0ee48ab5

See more details on using hashes here.

File details

Details for the file pyrudof-0.2.20-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrudof-0.2.20-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c18ad6b2220e5b39705106155aba62664fc9eb3f6751a1b8aa80593331d3d5a7
MD5 70c9a559c96108eba5965b0701f1e323
BLAKE2b-256 53f41dfdcaabab946e850a043728e8e35388ca70f2ec8b32c298e619950f2bcc

See more details on using hashes here.

File details

Details for the file pyrudof-0.2.20-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrudof-0.2.20-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 178c7b7e6bae1d1ceff2bc6c9c28c0361aa41f76a819b5f4c357a185b9019f76
MD5 8f919c51c6b2003002f647d1c4aa20d9
BLAKE2b-256 94b85afc52584c04227458d6d038046d04ee16cc4be7a46fe58fd6f898e2396a

See more details on using hashes here.

File details

Details for the file pyrudof-0.2.20-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyrudof-0.2.20-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4bbaa5a979561966997ef5c8d2314b4d97bdc7a520167f1b586bc8d75d4f22c7
MD5 4e31db22eef9981a26a055ae9db8eacc
BLAKE2b-256 6d789275cc4e6225fbf4a6a2ba0b1d050721bbac147fee05832bec5b34af1c7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page