Skip to main content

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 (1 ≠ 1.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.

Schema contracts

The full contracts surface ships in this binding (0.2.0+), in its batch-first shape:

  • Write-time enforcement needs nothing Python-specific — a sheet declaring implements rejects non-conforming writes through the shared core, byte-identically to Node, with the violated contract named on each issue.
  • canonical_contract_hash(document, format=None) — a contract document's identity: parsed data (a dict), or JSON/TOML text with an explicit format. Two parties holding the same logical document compute the same hash from either language.
  • verify_sheet_contract(git_dir, tree_ref, sheet, document, ...) — consumer-side verification, the module-level equivalent of Node's openSheet(name, { contract }):
report = gitsheets.verify_sheet_contract(
    git_dir, "HEAD", "meals", contract_doc, mode="verify",
)
# {'name': 'gitsheets.io/meals/v1', 'rung': 'declared', 'conforming': True,
#  'issues': [], 'tree': '9c41...'}

Modes: 'verify' (declared-identity fast path, falling back to structural record validation — the default), 'declared' (fast path only, never reads records), 'structural' (duck-typing any sheet, contract-aware or not). A failed verification raises ContractError (code contract_unsatisfied) carrying per-record issues.

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, validation, and schema contracts (enforcement, identity, and consumer verification — above).

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/

Metadata

Release files for gitsheets 0.6.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 gitsheets 0.6.0
File Size Uploaded Provenance
gitsheets-0.6.0.tar.gz 220.4 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for gitsheets 0.6.0
File
gitsheets-0.6.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
gitsheets-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
gitsheets-0.6.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
gitsheets-0.6.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
gitsheets-0.6.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
gitsheets-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 56.3 MB

Release files / gitsheets-0.6.0.tar.gz

Download URL gitsheets-0.6.0.tar.gz
Size 220.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6fd6e3c8fad5aab2cd73bd84ca3a697475a75f1dc218d7257260c22e39d0392e
BLAKE2b-256 checksum
How to use checksums
e96c3e7eae0fe4b1f8c669eccadc1a6e26001f67b6c1af98596ca8769c1dc7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-win_amd64.whl

Download URL gitsheets-0.6.0-cp39-abi3-win_amd64.whl
Size 9.0 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0d9b7c7df2f4c898c323f56748f997dda77f1901d0b9d31ddfd0d992ddc0f5dc
BLAKE2b-256 checksum
How to use checksums
09e18db916dbcb280066b392917fa312a18ec6d829e45afec001dea9704b6db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL gitsheets-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 10.2 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
73c243c7627fbc63ca0ea7ec7e3a6538bb8ad03100a996a5fb163807387aba87
BLAKE2b-256 checksum
How to use checksums
3c37bd8adb4d744d07fe072c6e4f79c3711c03f44010576d8aee207d6b7b31e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL gitsheets-0.6.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 9.6 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d8d460fc64e6eefffda11331ae1060131f6e9ec8bf685d2154c1d72502da5b37
BLAKE2b-256 checksum
How to use checksums
eb881c1c43538ca9d99a9d639a5200e7266143e746403f0be051524e5009ddb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL gitsheets-0.6.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 9.7 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
e686f7aea3e8ed31503d15b7477cd3e201f5169f73162d3f4874a7e67d2efece
BLAKE2b-256 checksum
How to use checksums
a0c78f89783ea59e1f3a812e75424326b436d237ff3ebfec67d1675b1f80cf57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL gitsheets-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Size 8.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8628c3223c76b853806f49682ccbdd6e543055963835335194bde36c89d5b554
BLAKE2b-256 checksum
How to use checksums
ca04072032a9aae16b8892989fe0c530a29fddbebb425b4db30ed225b66eaac2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / gitsheets-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL gitsheets-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 9.0 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1ba904e265894aaf22d6e62f17a07974271be3aec5e50cb7291f9afa36537b77
BLAKE2b-256 checksum
How to use checksums
e267540c82aff7f103d338587ebb06a5fef0a4ae0fb58cd7a3f0d34fe8ae9d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for gitsheets 0.6.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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for gitsheets-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

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.

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