diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 0adeb9b..a95468b 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 # required for correct CodSpeed integration with: python-version: ${{ env.UV_PYTHON }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 51739ae..784943e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: branches: - main - pull_request: tags: - 'v*.*.*' workflow_dispatch: @@ -90,8 +89,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: ${{ matrix.manylinux || 'auto' }} - container: ${{ matrix.container }} - args: --release --out dist --interpreter ${{ matrix.maturin-interpreter || matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 pypy3.11' }} ${{ matrix.extra-build-args }} + args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 pypy3.11' }} rust-toolchain: 1.76.0 docker-options: -e CI @@ -129,6 +127,10 @@ jobs: - name: Checkout repository. uses: actions/checkout@v4 + - uses: actions/setup-python@v5 # required for macos-13 with Python 3.8-3.10... otherwise UV uses PyPy... + with: + python-version: ${{ matrix.interpreter }} + - name: Install UV. uses: astral-sh/setup-uv@v6 with: diff --git a/.gitignore b/.gitignore index 445e552..c598a55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.py[cod] + # Generated by Cargo # will have compiled files and executables debug/ @@ -15,6 +17,7 @@ Cargo.lock # IDE .idea +*.iml .vscode # Python virtual environment @@ -30,4 +33,4 @@ __pycache__ .pytest_cache # Build artifacts -*.so \ No newline at end of file +*.so diff --git a/Cargo.toml b/Cargo.toml index 79cf1b3..94b2f41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libipld" -version = "3.0.1" +version = "3.1.0" edition = "2021" license = "MIT" description = "Python binding to the Rust IPLD library" diff --git a/README.md b/README.md index 4a1d320..81bcf8c 100644 --- a/README.md +++ b/README.md @@ -28,25 +28,32 @@ print(libipld.encode_multibase('u', b'yes mani !')) ### Features -- Decode DAG-CBOR (`decode_dag_cbor(bytes) -> dict`, `decode_dag_cbor_multi(bytes) -> list[dict]`) -- Encode DAG-CBOR (`encode_dag_cbor(obj) -> bytes`) -- Decode CID (`decode_cid(str | bytes) -> dict`). Accepts CID stringified form or CID raw byte form. -- Encode CID (`encode_cid(bytes) -> str`). Encodes CID raw byte form to stringified form. -- Decode Multibase (`decode_multibase(str) -> tuple[str, bytes]`). Returns base and data. -- Encode Multibase (`encode_multibase(str, bytes) -> str`). Accepts base and data. -- Decode CAR (`decode_car(bytes) -> tuple[dict, dict[bytes, dict]]`). Returns a header and blocks mapped by CID. CIDs in raw byte form. +#### 🔗 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 +- **`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 +- **`decode_dag_cbor(data: bytes) -> Any`** - Decode DAG-CBOR binary data into Python objects (dicts, lists, primitives) +- **`decode_dag_cbor_multi(data: bytes) -> list[Any]`** - Decode multiple concatenated DAG-CBOR objects from a single byte stream +- **`encode_dag_cbor(data: Any) -> bytes`** - Encode Python objects into DAG-CBOR binary format -## Requirements +#### 🌐 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'`) + +#### 🚗 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 + +### Requirements - Python 3.8 or higher. -## Installing +### Installing You can install or upgrade `libipld` via ```bash -pip install libipld +pip install -U libipld ``` ### Contributing diff --git a/python/libipld/_libipld.pyi b/python/libipld/_libipld.pyi index 889fb96..0f64d26 100644 --- a/python/libipld/_libipld.pyi +++ b/python/libipld/_libipld.pyi @@ -89,7 +89,7 @@ def decode_multibase(data: str) -> tuple[str, bytes]: """ -def encode_multibase(code: str, data: bytes | str) -> str: +def encode_multibase(code: str, data: str | bytes) -> str: """Encode data using multibase. Args: