Skip to main content

Python binding for snapdir — content-addressable directory snapshots.

Project description

snapdir — Python binding

Content-addressable directory snapshots for Python, powered by Rust.

Installation

pip install snapdir

Requires Python 3.10+ (abi3 wheel — one wheel covers all CPython ≥ 3.10).

Supported platforms: Linux (x86-64, aarch64), macOS (x86-64, arm64).

Quick start

import asyncio
import snapdir
from snapdir import SnapshotId, StoreUri

async def main():
    # Compute the snapshot ID for a directory (no I/O to any store)
    snap_id = await snapdir.id("/path/to/project")
    print(snap_id)  # 64-char lowercase hex BLAKE3 digest

    # Push to a store (file://, s3://, gcs://, b2://)
    store = StoreUri("s3://my-bucket/snapshots")
    snap_id = await snapdir.push("/path/to/project", store)

    # Pull (fetch from store + materialise files)
    await snapdir.pull(SnapshotId(snap_id), store, "/path/to/restore")

asyncio.run(main())

API reference

All I/O-bound operations are async. Sync helpers (version, id_from_manifest) need no event loop.

Async functions

Function Description
await manifest(path, *, no_follow, absolute, exclude) Walk path and return a Manifest (entries + raw text).
await id(path, *, no_follow, absolute, exclude) Compute the 64-hex snapshot ID without staging.
await stage(path) Stage path in the local cache; returns snapshot ID.
await push(path, store) Stage + upload to store; returns snapshot ID.
await fetch(snapshot_id, store) Download snapshot from store into local cache.
await pull(snapshot_id, store, dest) Fetch + materialise snapshot into dest.
await checkout(snapshot_id, dest) Materialise from local cache into dest.
await sync(snapshot_id, src, dst) Copy snapshot between two stores.
await diff(opts) Compare two sets of stores; returns list[DiffEntry].
await verify(snapshot_id, store) Verify snapshot integrity in store.

Sync functions

snapdir.version()               # "1.11.0"
snapdir.id_from_manifest(m)     # derive ID from an already-computed Manifest

Value types

  • SnapshotId(s) — validated 64-hex snapshot identifier.
  • StoreUri(s) — validated store URI (file://, s3://, gcs://, b2://).
  • DiffOptions.from_refs(from_uris, to_uris) — options object for diff().

Result types

  • Manifest.entries: list[ManifestEntry], .raw: str.
  • ManifestEntry.path, .path_type, .permissions, .checksum, .size.
  • DiffEntry.status ("A" / "D" / "M" / "="), .path.

Exceptions

All derive from SnapdirError (carries a .code string):

  • HashMismatchError — content checksum mismatch.
  • StoreError — store-level I/O / protocol error.
  • InFluxError — snapshot still being written (concurrent modification).
  • CatalogError — local catalog / cache integrity error.

Diffing two snapshots

import asyncio, snapdir
from snapdir import DiffOptions, SnapshotId, StoreUri

async def compare():
    store = StoreUri("s3://my-bucket/snapshots")
    opts = DiffOptions.from_refs(
        [f"{store}@{id_a}"],
        [f"{store}@{id_b}"],
    )
    for entry in await snapdir.diff(opts):
        print(entry.status, entry.path)

asyncio.run(compare())

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapdir-1.11.0.tar.gz (574.9 kB view details)

Uploaded Source

Built Distributions

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

snapdir-1.11.0-cp310-abi3-musllinux_1_2_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

snapdir-1.11.0-cp310-abi3-musllinux_1_2_aarch64.whl (11.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

snapdir-1.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view details)

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

snapdir-1.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

snapdir-1.11.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (21.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file snapdir-1.11.0.tar.gz.

File metadata

  • Download URL: snapdir-1.11.0.tar.gz
  • Upload date:
  • Size: 574.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapdir-1.11.0.tar.gz
Algorithm Hash digest
SHA256 c9dc33bc973bed0d7ae2f6f23fb9207936d3cf2bfa45a6cb9602ec2c0974b80c
MD5 641131ebf6246cb6286db4979e212f75
BLAKE2b-256 35412236eca8dd0d589526a87c6d2ddbc6a47d874c5309b22cb529e8d0f33aab

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0.tar.gz:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapdir-1.11.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for snapdir-1.11.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 40f121cc389fd7805f3808eabda46c06dd382ae43335da174a801676ea6f06bd
MD5 8fe149ed6948a35eef8b9df2b141da7f
BLAKE2b-256 56bb75ab7b2d748ccc7c20a3bc1f77878c1f404bda675f9f453ee20ac4364fc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapdir-1.11.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for snapdir-1.11.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d791895a50079dedec2e7c5f25c0ce01fa8ae66274373c777e7ec4b16c87b538
MD5 3535e4106d1bd80cfcb909d4be093914
BLAKE2b-256 50107e72922b31c733dbebffb79bf93c4efccb116daa90e2fbc057e7f246ae4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapdir-1.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapdir-1.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b049ccdc3f35887f59bee2b19412eafd82258cba367770e4c4de16db2e75032
MD5 227e4a39ec78fc055278a19b9ea911a9
BLAKE2b-256 0f8ade43d2653e93da867dbc3e8a965660641c6edacbe319ca1deb43abfd99d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapdir-1.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapdir-1.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 091b16177893925e3e5e05b39219e8d3de2856846c899a4e39e86e793784e50a
MD5 4f13bb680aadbd4b6891110c397f12ae
BLAKE2b-256 cbb2a95ce58dd3798702f56a15a4d56cd286aa6a97e8379b4f2fdfec06cb8671

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapdir-1.11.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for snapdir-1.11.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fe6c4c6071296ce1aa30af5ac76bb9a7a9d88527bc0e530c329cb7154684f8c2
MD5 26d1f40e7429ffc0933c8c3e1b1d9914
BLAKE2b-256 6eff8887b764998e03e1532d7ccfc38914875b19f263508de4bea144309bc7ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapdir-1.11.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on snapdir/snapdir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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