Skip to main content

pyshacl-turbo

PyPI version PyPI downloads Python 3.11+ Rust License: MIT OR Apache-2.0 Python coverage measured by pytest-cov pySHACL non-JS suite: 100% (403/403)

Tests and wheels Compatibility Regex

SHACL validation for Python, powered by Rust. The goal is a complete drop-in replacement for pySHACL, with additional features and better performance.

In our benchmarks, Turbo was 27–31× faster for SHACL rules and 123–126× faster for SPARQL pattern workloads than pySHACL 0.40.1 with RDFLib inputs. These measurements include shape compilation, input conversion and report construction, and require equivalent RDF validation reports. Some sparse workloads remain slower. Results depend on the data, shapes and input backend; the report includes all workloads, raw samples and measurement conditions.

Shape compilation, Core validation, SPARQL constraints, targets, rules and inference execute in Rust. Compile shapes once and reuse them across datasets; pass RDFLib graphs or PyOxigraph Stores directly. There is no runtime dependency on pySHACL or owlrl. Native execution releases the Python GIL.

Compatibility

The adapted pySHACL 0.40.1 non-JS regression suite passes 403/403 cases (100%). The W3C suite passes 120/120 with RDF document inputs and 119/120 with RDFLib Graph inputs. See the compatibility report for test methodology, suite adaptations and individual results. Passing these suites does not establish complete drop-in compatibility.

Current releases use the pyshacl_turbo import and pyshacl-turbo command. Remote SPARQL endpoint inputs and the HTTP server are not implemented, and some public APIs, complete inference output and report text still differ from pySHACL. SHACL-JS is planned. Review the known limits and direct API and CLI comparison before migrating.

Install

Requires Python 3.11+. Wheels are available for Linux x86-64/ARM64 (glibc 2.28+), macOS Intel/Apple Silicon, and Windows x86-64. Rust is only needed when building from source. This is an experimental release; the compatibility measurements and remaining limits above still apply.

For a uv project, run these from the directory containing pyproject.toml (create a project with uv init if needed):

uv add pyshacl-turbo

For optional PyOxigraph Store input, use:

uv add 'pyshacl-turbo[oxigraph]'

For a virtual environment managed with uv's pip interface:

uv venv --python 3.13
uv pip install pyshacl-turbo

Or use pip in your Python environment:

python -m pip install pyshacl-turbo

The same optional Store extra is available with either installer:

uv pip install 'pyshacl-turbo[oxigraph]'
# Or, with pip:
python -m pip install 'pyshacl-turbo[oxigraph]'

Command line

Run directly in an isolated uv tool environment:

uvx pyshacl-turbo data.ttl -s shapes.ttl
uvx --from pyshacl-turbo pyshacl-turbo-rules data.ttl -s rules.ttl

In a uv project where you have added the package:

uv run pyshacl-turbo data.ttl -s shapes.ttl
uv run pyshacl-turbo-rules data.ttl -s rules.ttl

To install both commands for regular use:

uv tool install pyshacl-turbo
pyshacl-turbo data.ttl -s shapes.ttl

If uv reports that its tool directory is missing from PATH, run uv tool update-shell and restart your shell. Tool environments are isolated; use uv add, uv pip install or pip for Python imports in your own project. Validation exits with status 0 for conforming data and 1 for violations.

Build

Requires Rust/Cargo, Python 3.11+ and uv. Development uses Python 3.13. The repository pins Rust 1.98.0 for compilation and formatting.

make dev
make check

Python

from pyshacl_turbo import compile_shapes, validate

conforms, report_graph, report_text = validate(
    "data.ttl", shacl_graph="shapes.ttl", advanced=True
)

# Compile once and reuse across independent datasets.
program = compile_shapes("shapes.ttl", advanced=True)
conforms, report_graph, report_text = program.validate("data.ttl")

Inputs include RDFLib Graph/Dataset objects, paths, URLs, file objects, RDF text and bytes. Supported formats include Turtle, N-Triples, N-Quads, TriG, RDF/XML, N3 and JSON-LD. Named graphs remain available to SPARQL GRAPH clauses; Core validation sees their union. Reports are RDFLib graphs by default.

PyOxigraph Store input is also supported. Install the optional oxigraph extra when PyOxigraph is not already installed:

from pyoxigraph import RdfFormat, Store
from pyshacl_turbo import validate

store = Store()
store.load(path="data.trig", format=RdfFormat.TRIG)
conforms, report, text = validate(store, shacl_graph="shapes.ttl", advanced=True)

The Store input path avoids an intermediate RDFLib data graph. Independent Python extensions exchange a native N-Quads snapshot, so it is not zero-copy. See Store input details. Named graphs and blank-node labels are preserved. Literal spellings already normalized by a caller's Store cannot be recovered. Store rule and inference additions commit atomically only with inplace=True, after successful execution. Only new quads are committed; concurrent deletion of input quads is not undone.

RDFS and OWL-RL inference are implemented natively and selected with inference="rdfs", "owlrl" or "both". Inferred graphs contain standard RDF: literal values remain objects, and triples with literal subjects are intentionally excluded. This is a documented inference contract; differences involving valid RDF remain subject to compatibility testing. owlrl is installed only by the reference-test extra, not as a runtime backend.

Core and SPARQL patterns support Python-compatible regexes, including lookarounds and backreferences. Count and length bounds retain exact arbitrary-precision values. See the compatibility details for regexes and integer parameters.

Rust

The standalone pyshacl-turbo-engine crate accepts exact-term oxrdf Dataset values and oxigraph::Store inputs. CompiledShapes::validate_store and expand_store copy a consistent quad snapshot without RDF text conversion. Their inplace flag controls atomic addition of derived quads to the Store. Compiled programs are shareable across threads; parallelism is caller-controlled.

Shape compilation uses shacl-structural-model with Turbo's exact RDF terms, then prepares native queries, regexes and indexes for execution. The original graph remains available for reports and source identity. See ADR 0017.

Performance

The benchmark results compare Core validation, increasing shape counts, SHACL rules and SPARQL patterns through both RDFLib and Store inputs. Timings are medians of five interleaved samples on macOS Apple Silicon with Python 3.13. They include input conversion and report construction; full RDF report parity is required before timing. File I/O, process startup and fixture construction are excluded. Background build activity was observed and is documented in the report.

Fresh RDFLib inputs include shape compilation. Separate measurements show the effect of reusing compiled shapes and using an already loaded Store. Sparse targeting can be slower because Turbo copies the input graph even when few nodes need validation. Small API-call timings with stricter output and interface checks are in the direct comparison.

make benchmark

Earlier measurements cover inference, compiler integration, Core patterns and SPARQL patterns. Each report records the source revision or hashes and measurement conditions. Inference timings remain provisional wherever complete inferred graphs differ, even when validation reports agree. Reference backend errors are recorded without assigning a speedup. Benchmark your own workloads before drawing capacity estimates.

# Run alone, separately from builds and other tests.
.venv/bin/python benchmarks/check_core.py

# Full-report-gated SPARQL regex and replacement comparison.
.venv/bin/python benchmarks/matrix.py --kinds sparql-patterns --repeats 7 --output benchmarks/sparql-patterns.json

# Original SPARQL pipeline comparison, including both reference backends.
make benchmark-pipeline

Verification and architecture

Local regressions compare full reports, rule output, graph mutation, blank-node identity, namespace handling, Store inputs and errors. Pinned W3C and pySHACL assets live under tests/w3c and vendor/pyshacl respectively.

make coverage
make test-compatibility
make test-regex
make test-sparql-evaluator
make test-coverage
.venv/bin/python scripts/run_upstream.py
.venv/bin/python scripts/run_upstream.py --reference
.venv/bin/python scripts/audit_reference_fixture.py

The three workflow badges report required CI checks on main. Each workflow also runs on pull requests, daily, and on manual dispatch:

Workflow What it verifies
Tests and wheels Python and Rust regressions, formatting and lint on Linux Python 3.11/3.13 and macOS Python 3.13; SPARQL evaluator tests with compatibility features disabled and enabled; source archive rebuilt into all five platform wheels. Every wheel is checked with uv pip, locked uv add/uv run projects, the optional Store extra, uvx and uv tool install, including both CLIs and validation exit codes. The release also requires Compatibility and Regex at the same prepared revision.
Compatibility Pinned W3C Core/SPARQL cases through document and Graph APIs, the adapted non-JS pySHACL suite, and direct API/CLI comparisons. Suite adaptations are independently checked against both engines. Detailed reports are uploaded as artifacts.
Regex The patched matcher's full upstream suite, unit tests with Turbo's base features, Python-mode VM regressions, and formatting, using its own pinned test dependencies.

The Python coverage report measures the complete pyshacl_turbo Python package with pytest-cov, including uncovered files and branches. CI requires 100% line and branch coverage on Linux Python 3.13. XML, JSON and HTML reports are uploaded for each run; passing main runs publish the HTML report and measured percentage badge to GitHub Pages. make test-coverage generates the same report locally in htmlcov/. This measures Python API/CLI code coverage; it does not measure Rust code coverage or SHACL compatibility. No package files are omitted from the denominator.

A green Compatibility badge means the documented suite baselines hold. The compatibility report records suite adaptations and the expected W3C Graph difference. CI also runs direct API and CLI comparisons: previously matching cases and fields must remain equal, while known differences and reference failures stay visible. These badges do not claim complete pySHACL compatibility.

Architectural decisions are in docs/adr. The exact-term dataset avoids premature literal canonicalization. Documented local Rust dependency patches preserve RDFLib string identity and SHACL SPARQL prebinding.

PRs use conventional titles and squash merges; main requires signed commits, passing prepare, test, compatibility, regex, and Conventional Commit checks, and the configured owner review. Repository maintenance follows the public Legra release policy and the shared legra-ai/github-actions pipeline. Release artifacts and recovery are described in releasing.

License

Original project code is dual-licensed under MIT or Apache-2.0, at your option (MIT OR Apache-2.0). Copyright 2026 DataRoad Inc, Delaware, USA, trading as Legra. Vendored code and assets retain their licenses and provenance.

Metadata

Release files for pyshacl-turbo 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyshacl-turbo 0.1.3
File Size Uploaded
pyshacl_turbo-0.1.3.tar.gz 904.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyshacl-turbo 0.1.3
File
pyshacl_turbo-0.1.3-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
pyshacl_turbo-0.1.3-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pyshacl_turbo-0.1.3-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 18.8 MB

Release files / pyshacl_turbo-0.1.3.tar.gz

Download URL pyshacl_turbo-0.1.3.tar.gz
Size 904.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7d4e8e3b73cb731d7136334d19ba019a644950f0780f412685bdeb5bb48a5240
BLAKE2b-256 checksum
How to use checksums
72f3987d00779a65fdc5d093341d52755a7c93a9e5189a2a6251f4715871b090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.3-cp311-abi3-win_amd64.whl

Download URL pyshacl_turbo-0.1.3-cp311-abi3-win_amd64.whl
Size 3.6 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
562b5133586287c9e73152b1549e1dc85c8168f94aed74a9345ca4ff47926ff4
BLAKE2b-256 checksum
How to use checksums
f6f2fc3aea40ab805d90866268de628bfafbb5290bfd1dd35f38d209f6d4bffb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_x86_64.whl
Size 3.6 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
05bbc676ce06f3ca5cfcdb6fc69b9d5f4af84909a7e0c325a24c18d298b31d51
BLAKE2b-256 checksum
How to use checksums
b57ffe9f278951e9e19fbeff34f9fd5331dadca19b356eefb70c62fba5a7efd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL pyshacl_turbo-0.1.3-cp311-abi3-manylinux_2_28_aarch64.whl
Size 3.5 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
dae4b9596f0fbc7ce03aaf243bb32f1fad5093c74cc0a71276294cdc6fc0a80a
BLAKE2b-256 checksum
How to use checksums
9458993449225cac13bf563b156ea550199cd53b6a80235c02602a52089c9215
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.3-cp311-abi3-macosx_11_0_arm64.whl

Download URL pyshacl_turbo-0.1.3-cp311-abi3-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
18fce5e3036b50ec860cd1ee21be6dcc563f2a08c8570c91cc745b4f92ce5201
BLAKE2b-256 checksum
How to use checksums
0f4de9e5c9fdd29e7604688a263f7ed3ac2935dfbb9318e2504df8e0c48a1752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.3-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pyshacl_turbo-0.1.3-cp311-abi3-macosx_10_12_x86_64.whl
Size 3.7 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
64b5ca04c81c385f1bdd546c4c594154ee9fbdf288832ce682f0a20a122c0f5c
BLAKE2b-256 checksum
How to use checksums
a98959a88ba451c867817298decc1e989e2c2535ae45d924d54563c59567a299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.4

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.1

6 release files

0.2.0

6 release files

This release

0.1.3 This release

6 release files

0.1.2

6 release files

0.1.1

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page