Skip to main content

gitoxide-py

Python bindings to gitoxide (the gix Rust crate), built with PyO3 and maturin.

Status: alpha, work in progress.

Started from shenxianpeng/gitoxide (MIT OR Apache-2.0) and reworked from there: every call releases the GIL, the read surface covers diffs, reflogs, the index and submodules, and ref edits are supported. Distributed as gitoxide-py, separately from that project's gitoxide package.

Design goals

  • API parity with gix. Method and function names mirror gix's own Rust API where a direct equivalent exists (open/discover/init, git_dir/workdir, head_id/head_commit, rev_parse_single, rev_walk/commits, ...), rather than mimicking GitPython's API shape.
  • The GIL is released for every call. Every method wraps its gix work in Python::detach, so other Python threads keep running while a call is in flight. See the module doc comment in src/lib.rs for why Repository is backed by gix::ThreadSafeRepository rather than gix::Repository — the latter is never Sync (internal RefCell-based object cache), so it can't satisfy detach's Send bound no matter how the pyclass is annotated.
  • Typed, with no hand-maintained stub file. pyo3's experimental-inspect feature embeds type introspection data into the built binary; maturin build/develop --generate-stubs extracts it and bundles the result into the wheel as a proper gitoxide_py/ package (__init__.py + .pyi + py.typed, PEP 561), so mypy/pyright resolve real types against the installed package with no extra configuration — and the stub can never drift from the actual API, since it's generated from the same binary. Requires the declarative #[pymodule] mod gitoxide_py { ... } style in src/lib.rs; introspection doesn't support the older function-style #[pymodule] fn gitoxide_py(m: &Bound<PyModule>) -> PyResult<()> { ... }.

Building

uv manages the environment — maturin and pytest are declared as a dev dependency group in pyproject.toml, locked in uv.lock.

uv sync
uv run maturin develop --release --generate-stubs

API

The generated stub (gitoxide_py/__init__.pyi in the installed package) carries the full signature and doc of every function, method and attribute, so editors and type checkers describe the API without a second copy of it living here.

Testing

uv run pytest -v

The tests build fixture repositories with the real git CLI and exercise the API against them. test_gil_release.py is the exception: it asserts that Python::detach actually lets another Python thread make progress during a call, via the _debug_detached_sleep helper (not part of the public API).

CI (.github/workflows/ci.yml) runs on a self-hosted runner: cargo fmt --check, cargo clippy -D warnings, uv run maturin develop --release --generate-stubs, then uv run pytest -v.

Scope

Alpha. Reading, plus the writes that are a ref edit and nothing more: creating and deleting branches and tags, and setting local configuration. Nothing here touches the working tree.

Covered: open/discover/init; HEAD and branch state; rev-parse and object kinds; commit walks, in graph, date or topological order; merge-base, ahead/behind and ancestry checks; tree entries and blob reads; tree-to-tree diffs, with per-file line counts on request; remotes; linked worktrees; submodules and their status; index entries and conflict stages; working-tree status; reflogs; configuration reads and writes; and branch and tag creation and deletion.

Not covered: anything over the network (fetch/push/clone need a transport feature and a TLS backend, a dependency decision of its own), and anything that writes commits, index entries or the working tree. Note that those are also where git runs hooks — it runs none for a ref edit, and neither does this.

Layout

src/lib.rs assembles the Python module out of items defined beside it: src/repository.rs holds the Repository handle and the functions that open one, src/types.rs the value objects its methods return, and src/util.rs the conversions they share.

Download files

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

Source Distribution

gitoxide_py-0.87.0.tar.gz (62.6 kB view details)

Uploaded Source

Built Distributions

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

gitoxide_py-0.87.0-cp39-abi3-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

gitoxide_py-0.87.0-cp39-abi3-manylinux_2_39_x86_64.whl (2.9 MB view details)

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

File details

Details for the file gitoxide_py-0.87.0.tar.gz.

File metadata

  • Download URL: gitoxide_py-0.87.0.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for gitoxide_py-0.87.0.tar.gz
Algorithm Hash digest
SHA256 9839881ce6077985a727c5369e36a69d9ca15b7a24eb3040b49c6a43e28845fd
MD5 b1d772e570066b5fbcbf1b51c994bf76
BLAKE2b-256 014d1c4e3449a3a76635a657f103d1e0c4c954a19934904becae1351f37e2e3b

See more details on using hashes here.

File details

Details for the file gitoxide_py-0.87.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: gitoxide_py-0.87.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for gitoxide_py-0.87.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a41ea29b5e935cee5d5fe199099ceb58a8e85690c6f1efb66bb0ecb6e816c4c8
MD5 e376a0d26f4d6ecfcbad3cd19cd782ba
BLAKE2b-256 67531e45b162b65b3b5fd7c5a2441c054c65cf03c9fb69b2cfde652dd2d4343c

See more details on using hashes here.

File details

Details for the file gitoxide_py-0.87.0-cp39-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for gitoxide_py-0.87.0-cp39-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 0dc272f2d9261d257a6e2c3347255937aba1b72425253de513129d9f0e326795
MD5 2140381ed4dd4940546cdc680874a883
BLAKE2b-256 882f9ff21d4551b2f2ea7288b76e5eddb1b6de9796b3be5826c99a82267c3d90

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.87.0 This release

3 files

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