Skip to main content

RDF Canonicalisation

License PyPI Downloads

A Python library for RDF canonicalisation based on the W3C RDF Canonicalisation specification. This library allows you to deterministically canonicalise RDF datasets, making it easier to compare, sign, or hash RDF graphs.

Features

  • Deterministic RDF blank node canonicalisation
  • Support for multiple hash algorithms (e.g., sha256)
  • Integration with rdflib Dataset objects
  • Time-based ticker for controlling the maximum duration of the canonicalisation task.

Installation

pip install rdfcanon

Usage

from rdfcanon import RDFCanon, RDFCanonTimeTicker
from rdflib import BNode, Dataset, URIRef

# Create a sample RDF dataset
dataset = Dataset()
dataset.add(
    (
        BNode("e0"),
        URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
        URIRef("http://example.org/vocab#Foo"),
        BNode("g0")
    )
)

# Initialise RDF canonicalisation
rdf_canon = RDFCanon(
    hash_algorithm="sha256",
    dataset=dataset,
    ticker=RDFCanonTimeTicker(3000)  # Optional time ticker
)

# Canonicalise the RDF dataset
print(rdf_canon.canonize())

This will output:

_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/vocab#Foo> _:c14n0 .

Development

Build the library

python setup.py sdist bdist_wheel

Run tests

pytest

Contributing

Contributions are welcome! Please submit issues or pull requests via GitHub.

License

MIT License © 2025 YoucTagh

Metadata

Release files for rdfcanon 1.0.0

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

Source distribution (sdist)

Source distribution for rdfcanon 1.0.0
File Size Uploaded Provenance
rdfcanon-1.0.0.tar.gz 10.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rdfcanon 1.0.0
File Interpreter ABI Platform
rdfcanon-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / rdfcanon-1.0.0.tar.gz

Download URL rdfcanon-1.0.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
adc75fa9bd936761d2a5de4a0299ab658446454437ecfb4886c6bf55ee9ddaa1
BLAKE2b-256 checksum
How to use checksums
8968b3036862e7292684607c9ff5e8d11c09d4a34a7b792870d19ed4035bc7ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / rdfcanon-1.0.0-py3-none-any.whl

Download URL rdfcanon-1.0.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
100a48239044f9cc5342e1d16ccfb806d47bb1bb5cc577ebefd20a81117bf14c
BLAKE2b-256 checksum
How to use checksums
df9b31d254f4ebaf166d055deb921211f9a2c5b9a5d63085f7c03f1501c64acd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for rdfcanon 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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