Skip to main content

Python binding for gitsheets-core — a git-backed document store, over the shared Rust engine.

Project description

gitsheets (Python)

The Python binding for gitsheets — a git-backed document store for low-volume, high-touch, human-scale data. Records are canonical TOML files in a git tree; every write is a real git commit you can diff, review, revert, and sync like any other.

The guarantee that defines this package: a record written from Python and the same record written from the Node.js gitsheets package produce byte-identical trees, blobs, and commits. The binding is a thin pyo3 layer over the shared Rust gitsheets-core engine; everything that determines on-disk bytes (canonical TOML, path-template rendering, JSON-Schema validation, the embedded JS engine, the Sheet/Transaction/Store state machine) lives in the core, and a cross-binding parity suite proves the byte equivalence in CI on every change.

Install

pip install gitsheets

Prebuilt abi3 wheels (any CPython >= 3.9) ship for Linux x86_64 + aarch64 (glibc), Linux x86_64 (musl), macOS x86_64 + arm64, and Windows x86_64. Other platforms install from the sdist, which needs a Rust toolchain.

Quick start

A sheet is declared by a TOML config committed in the repo — here, one record file per person, keyed by slug, under people/:

mkdir crm && cd crm && git init -b main
mkdir .gitsheets
cat > .gitsheets/people.toml <<'EOF'
[gitsheet]
path = '${{ slug }}'
root = 'people'
EOF
git add .gitsheets && git commit -m "declare the people sheet"

Write records inside a transaction — commit on success, discard on error:

import time
import gitsheets

with gitsheets.transact(
    ".git",                       # the repo's GIT_DIR
    "people: add jane",           # commit message
    int(time.time()),
    author=("Jane Doe", "jane@example.org"),
    branch="refs/heads/main",
) as tx:
    tx.open_sheet("people", ".gitsheets/people.toml")
    tx.upsert("people", {"slug": "jane", "email": "jane@example.org"})

print(tx.result["commit_hash"])

The round-trip is plain git — and the bytes are canonical, identical to what the Node binding would have written:

$ git show main:people/jane.toml
email = "jane@example.org"
slug = "jane"

Type fidelity

The binding marshals Python natives ↔ the core's TOML-faithful value type:

Python core Value TOML
int Integer (i64) integer (distinct from float)
float Float (f64) float (11.0)
str String string
bool Boolean boolean
datetime.datetime Datetime datetime (aware UTC instant)
dict Table table
list / tuple Array array

Python's int is arbitrary-precision, so small ids stay ergonomic and large values never lose precision (an int outside the i64 range TOML permits raises OverflowError).

Consumer validators

The runtime consumer-validator hook runs Python-side on the normalized record before the core writes any bytes — pass any callable (a Pydantic Model.model_validate, a Zod-style check, a plain assertion):

import gitsheets
from pydantic import BaseModel

class Person(BaseModel):
    slug: str
    email: str

with gitsheets.transact(git_dir, "add jane", time_seconds, author=("Jane", "jane@x.org"), branch="refs/heads/main") as tx:
    tx.open_sheet("people", ".gitsheets/people.toml")
    tx.upsert("people", {"slug": "jane", "email": "jane@x.org"}, validate=Person.model_validate)

JSON-Schema validation declared in the sheet config runs in-core, identically to the Node binding.

What 0.x is (and isn't)

The 0.x releases are honestly scoped as a transactional writer with parity-proven reads: transact/Transaction (open_sheet, upsert, delete, clear, will_change), attachments (set_attachment(s)/get_attachment(s)/delete_attachment(s)), reads through opened sheets, and validation.

Known gaps, tracked in #240 and stated plainly rather than papered over:

  • No freshness model — no refresh/auto-refresh after commit; reads see the tree a transaction opened, not later commits.
  • No streaming blob reads — attachments surface as blob hashes; there is no streaming read API yet.
  • No push daemon — syncing the repo to remotes is yours to arrange.

These reach parity with the Node binding as #240 lands.

Versioning and releases

Releases ship from the py-v* tag track: the released version is committed in rust/gitsheets-py/Cargo.toml, the tag must match it, and every release is built from a commit whose cross-binding byte-parity suite is green. Pre-1.0 semver: breaking surface changes bump the minor version.

Development

Build a local wheel and run the smoke + cross-binding parity suite:

uv venv && uv pip install maturin pytest pydantic
uv run maturin develop
uv run pytest tests/

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

gitsheets-0.1.0.tar.gz (155.9 kB view details)

Uploaded Source

Built Distributions

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

gitsheets-0.1.0-cp39-abi3-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

gitsheets-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl (9.7 MB view details)

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

gitsheets-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

gitsheets-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl (9.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

gitsheets-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

gitsheets-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (8.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file gitsheets-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for gitsheets-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cbdc9b40950681a8059e88cca161895f9da0d262f432b2d6c8eee7b2a85b931c
MD5 a753a76c91b6e94bf61071fba82b929b
BLAKE2b-256 029f37a1700002584bb1d5d5e43ff29cde9705bc03f465d4415b028e7515162c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0.tar.gz:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: gitsheets-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 23995ca7c3cb4c1cc34d0e0397075174480532720f1ef2be5369a11528e60c55
MD5 75f56268b6e541fa61e3e2e9a7844c4b
BLAKE2b-256 23f7e1ec51f0e6de094e6bbdf270f3a5032d651a03149d90228c87a98f969aa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9923a054c4e45577792b5dc60ed57ef541aa48f557815d5891e23604db7d05e8
MD5 6c0a99b913f121f205eab8a2cd733f2d
BLAKE2b-256 88754145b956ec4d7d051f030c3e7d4c691fe9835324adeb866e397e9f5a1173

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f59d7a6e0f42065b310e54ee79b87884916faa4962d09488a8c9eb065aa318e7
MD5 7d77484b0a5a5a2fbab172a85cc9de0e
BLAKE2b-256 1909dd45be5f39405046f27dac64ba4417bb574cf2fc6d1b9c0f7af42a64f3fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5ea1da93c706645a674376a120a3c3522102522adb653373f60578008cdedc1c
MD5 0f93af1a41027ce62ea4c802895f6391
BLAKE2b-256 2669f02dfedbb6b56796a576164f050fae404fd5e36e9844d48d427c92b042bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5abe12c80e2247a5db1ea38e6666fadcef6de5cca5678493176da790c8b4697
MD5 a48b672f8bd243b8135e5331301a0318
BLAKE2b-256 a10411fc528d74ddfba83af9815a61297f5bf26250c823d74169cdd3c831f9cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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

File details

Details for the file gitsheets-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for gitsheets-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dbfd68423e04ba7b9a1afc88564e8a6df2a08851a8c419bc006eb47c862132fc
MD5 5bb8f8b7b9b03546c13403dc8e18d8ab
BLAKE2b-256 4c9348a7eb955318bd9a3038a71c104d6a1f9e563bb36abfc6590ed770552da2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitsheets-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: python-publish.yml on JarvusInnovations/gitsheets

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