Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,20 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
if: startsWith(github.ref, 'refs/tags/v')
needs: [ build, build-pgo, build-sdist, check ]
environment:
name: pypi
url: https://pypi.org/project/libipld/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
pattern: pypi_*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@v1.14.2
with:
command: upload
args: --non-interactive --skip-existing dist/*
skip-existing: true
518 changes: 518 additions & 0 deletions CHANGES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Contibuting to python-libipld
## Contributing to python-libipld

This project is a small, single-file wrapper around Rust crates like `cid`, `cbor4ii`, and `multibase`, exposing a Python API through `PyO3`. Despite its size, performance matters a lot.
This project is a small wrapper around Rust crates like `cid` (which also provides multibase) and `cbor4ii`, exposing a Python API through `PyO3`. Despite its size, performance matters a lot.

The project uses `uv` package manager. Installing UV: https://docs.astral.sh/uv/getting-started/installation/

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libipld"
version = "3.4.1"
version = "3.5.0"
edition = "2021"
license = "MIT"
description = "Python binding to the Rust IPLD library"
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ print(libipld.encode_multibase('u', b'yes mani !'))
### Features

#### 🔗 CID (Content Identifier) Operations
- **`decode_cid(data: str | bytes) -> dict`** - Decode CIDs from string representation (e.g., `'bafy...'`) or raw bytes into structured data containing version, codec, and hash information
- **`decode_cid(data: str | bytes) -> dict[str, Any]`** - Decode CIDs from string representation (e.g., `'bafy...'`) or raw bytes into structured data containing version, codec, and hash information
- **`encode_cid(data: str | bytes) -> str`** - Encode CID raw bytes to string representation, or return string CIDs as-is

#### 📦 DAG-CBOR (Directed Acyclic Graph CBOR) Operations
Expand All @@ -39,10 +39,10 @@ print(libipld.encode_multibase('u', b'yes mani !'))

#### 🌐 Multibase Operations
- **`decode_multibase(data: str) -> tuple[str, bytes]`** - Decode multibase-encoded strings, returning the base identifier and decoded data
- **`encode_multibase(code: str, data: str | bytes) -> str`** - Encode data using specified multibase encoding (e.g., base58btc with code `'u'`)
- **`encode_multibase(code: str, data: str | bytes) -> str`** - Encode data using specified multibase encoding (e.g. `'u'` for base64url)

#### 🚗 CAR (Content Addressable Archives) Operations
- **`decode_car(data: bytes) -> tuple[dict, dict[bytes, dict]]`** - Decode CAR files into header metadata and a mapping of CID bytes to block data
- **`decode_car(data: bytes) -> tuple[dict[str, Any], dict[bytes, dict[str, Any]]]`** - Decode CAR files into header metadata and a mapping of CID bytes to block data

### Error handling

Expand All @@ -69,6 +69,8 @@ Passing a value of the wrong type, such as a `str` where `bytes` is expected, ra

- Python 3.8 or higher.

Prebuilt wheels are published for CPython 3.8-3.15, free-threaded CPython 3.14t and 3.15t, and PyPy 3.11.

### Installing

You can install or upgrade `libipld` via
Expand All @@ -81,7 +83,7 @@ pip install -U libipld

Benchmarks against [`cbrrr`](https://github.com/DavidBuchanan314/dag-cbrrr) (C), [`py-ipld-dag`](https://github.com/ipld/py-ipld-dag) (Python wrapper over Rust-backed [`cbor2`](https://github.com/agronholm/cbor2)) and [`dag_cbor`](https://github.com/hashberg-io/dag-cbor) (pure Python), measured on the four classic [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) fixtures (round-tripped through DAG-CBOR). Bars are operations/second relative to pure-Python `dag_cbor`; higher is better.

Measured on Apple M1, macOS 15 (Darwin 24.6.0), CPython 3.14.0, `libipld` installed from PyPI (PGO + LTO wheel).
Measured on Apple M1, macOS 27, CPython 3.14.0, `libipld` installed from PyPI (PGO + LTO wheel).

#### Deserialization

Expand All @@ -99,6 +101,10 @@ cd benchmark && ./run.sh

See [`benchmark/README.md`](./benchmark/README.md) for details.

### Changelog

See [`CHANGES.md`](./CHANGES.md) for release notes.

### Contributing

Contributions of all sizes are welcome. See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for setup, build, test, and benchmarking workflow.
Expand Down
Binary file modified benchmark/deserialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmark/serialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
]
license = "MIT"
readme = "README.md"
keywords = ["library", "lib", "ipld", "cid", "multibase", "multihash", "dag", "cbor", "dag-cbor"]
keywords = ["ipld", "cid", "car", "multibase", "multihash", "dag", "cbor", "dag-cbor", "atproto", "bluesky", "rust"]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -38,6 +38,7 @@ classifiers = [
"Homepage" = "https://github.com/MarshalX/python-libipld"
"Repository" = "https://github.com/MarshalX/python-libipld"
"Tracker" = "https://github.com/MarshalX/python-libipld/issues"
"Changelog" = "https://github.com/MarshalX/python-libipld/blob/main/CHANGES.md"
"Author" = "https://github.com/MarshalX"

[dependency-groups]
Expand Down
2 changes: 1 addition & 1 deletion python/libipld/_libipld.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def encode_multibase(code: str, data: str | bytes) -> str:
"""Encode data using multibase.

Args:
code: Base code (e.g. 'u' for base58btc)
code: Base code (e.g. 'u' for base64url, 'z' for base58btc)
data: Data to encode (bytes or string that can be converted to bytes)

Returns:
Expand Down
Empty file added python/libipld/py.typed
Empty file.
Loading