Fast, safe, pure-Rust Git for Python — bindings to the gitoxide engine and a modern alternative to GitPython
Project description
gitoxide-python
Fast, safe, pure-Rust Git for Python — bindings to the gitoxide engine, and a modern alternative to GitPython.
gitoxide (the gix crate) is a next-generation, pure-Rust implementation of
Git.
This project exposes that engine to Python through PyO3 and ships as pre-built wheels via maturin, so you get:
| GitPython | pygit2 | gitoxide-python | |
|---|---|---|---|
| Backend | shells out to the git CLI |
C libgit2 |
pure-Rust gix |
| Speed | slow (spawns a subprocess per call) | fast | fast (in-process, no subprocess) |
| Install | needs git on PATH |
needs a C toolchain / system libgit2 |
pip install, self-contained wheels |
| Memory safety | n/a (subprocess) | C | Rust |
Status: alpha. The binding surface is small but real and growing. It currently covers read-oriented workflows (open/discover, HEAD, history walk, refs, branches, tags, blob reads) — the operations DevOps tooling reaches for most. See Roadmap.
Installation
pip install gitoxide
Pre-built wheels are published for Linux (manylinux, x86_64 + aarch64), macOS
(x86_64 + Apple Silicon), and Windows — no Rust toolchain or system libgit2
required.
From source
Building from a checkout (or from the sdist on an unsupported platform) requires a Rust toolchain:
pip install maturin
maturin develop # build + install into the active virtualenv
# or build a wheel:
maturin build --release
Quick start
import gitoxide
repo = gitoxide.open(".") # or gitoxide.discover(".")
print(repo.git_dir) # .../my-project/.git
print(repo.workdir) # .../my-project (None if bare)
print(repo.is_bare) # False
print(repo.head_name) # 'main' (None if detached)
# The commit at HEAD
head = repo.head_commit()
print(head.short_id, head.summary)
print(head.author.name, head.author.email, head.author.time)
# Walk history (reverse-chronological), like `git log`
for commit in repo.commits(max_count=10):
print(commit.short_id, commit.author.name, commit.summary)
# Resolve a revspec to an object id
print(repo.rev_parse("HEAD~2"))
print(repo.rev_parse("main"))
# Branches, tags, and all references
print(repo.branches()) # ['main', 'dev', ...]
print(repo.tags()) # ['v1.0.0', ...]
for ref in repo.references():
print(ref.name, "->", ref.target)
# Read a file's content at a revision
readme = repo.read_blob("HEAD:README.md")
print(readme.decode())
Migrating from GitPython
Common operations, side by side:
| GitPython | gitoxide-python |
|---|---|
from git import Repo |
import gitoxide |
repo = Repo(path) |
repo = gitoxide.open(path) |
Repo(path, search_parent_directories=True) |
gitoxide.discover(path) |
repo.head.commit |
repo.head_commit() |
repo.active_branch.name |
repo.head_name |
repo.iter_commits("main", max_count=10) |
repo.commits("main", max_count=10) |
repo.commit("HEAD~2") |
repo.commit("HEAD~2") |
repo.rev_parse("main").hexsha |
repo.rev_parse("main") |
[b.name for b in repo.branches] |
repo.branches() |
[t.name for t in repo.tags] |
repo.tags() |
c.hexsha, c.summary, c.author.name |
c.id, c.summary, c.author.name |
The key difference is what happens underneath: GitPython's iter_commits spawns
a git rev-list subprocess; gitoxide-python walks the object database
in-process in Rust.
API
Module functions
gitoxide.open(path) -> Repositorygitoxide.discover(path) -> Repository— searchpathand its parentsgitoxide.init(path, bare=False) -> Repositorygitoxide.gix_version() -> str
Repository
Properties: git_dir, workdir, is_bare, is_shallow, head_id,
head_name, head_is_detached.
Note:
head_nameandhead_is_detachedaccess theHEADreference and may raiseGitoxideErrorif it is inaccessible (e.g., corrupted repository). Other properties never raise.
Methods: head_commit(), rev_parse(spec), commit(rev),
commits(rev=None, max_count=None), references(), branches(), tags(),
read_blob(rev).
Commit
id, short_id, tree_id, message, summary, author, committer,
parents.
Signature
name, email, time (Unix seconds), offset (UTC offset seconds).
Reference
name, shorthand, target.
All errors (from any function or method) are raised as
gitoxide.GitoxideError.
Roadmap
- Diffing and status
- Tree traversal / listing entries
- Writing commits, staging (index), tag/branch creation
- Blame
- Cloning and remote operations (fetch/push)
- Lazy commit iterators instead of eager lists for very large histories
Contributions welcome — the binding layer lives in a single src/lib.rs
and maps cleanly onto the gix API.
Development
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest
maturin develop # build the extension into the venv
pytest -q # run the test suite
cargo fmt --all # format Rust
cargo clippy --all-targets -- -D warnings
The tests generate a throwaway git repository on the fly (see
tests/conftest.py), so they need git on PATH but
touch nothing outside a temp directory.
License
Licensed under either of Apache License 2.0 or MIT license at your option, to match the upstream gitoxide project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitoxide-0.1.0.tar.gz.
File metadata
- Download URL: gitoxide-0.1.0.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e28debcf4985c64c905810fcebe6e2fa462a79c7d9eeae69b84bdf79bdfcc9b4
|
|
| MD5 |
e2fbcdd1a799af04899559bb3e4053fe
|
|
| BLAKE2b-256 |
0ebc0ff3d450dbc123753fdad420b7ddd04aa7bb8db54c76298f66ed0859b16e
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0.tar.gz:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0.tar.gz -
Subject digest:
e28debcf4985c64c905810fcebe6e2fa462a79c7d9eeae69b84bdf79bdfcc9b4 - Sigstore transparency entry: 2154322867
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitoxide-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: gitoxide-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15e8d19d1bd02d90b62315f682dc74c64e68d6f272960199f1728f91f0c7a0b
|
|
| MD5 |
521aeddad66ceffdbe3df7f51e5a897e
|
|
| BLAKE2b-256 |
fa38e68d61de829d937e3ea9763b8a05b3b9c66ee3a80da5fb03a5a760238f01
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0-cp39-abi3-win_amd64.whl:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0-cp39-abi3-win_amd64.whl -
Subject digest:
f15e8d19d1bd02d90b62315f682dc74c64e68d6f272960199f1728f91f0c7a0b - Sigstore transparency entry: 2154323589
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitoxide-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: gitoxide-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823d652194eddd82d3c6b975a6cbbc0285419d525124831db026ed34dc8207ef
|
|
| MD5 |
91fb1f1700c2c74e9ce9857358428df0
|
|
| BLAKE2b-256 |
3066bf4cdbed314066104ad8bc6d2fea6b9931465dc278e78ff84ece8493ee3e
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
823d652194eddd82d3c6b975a6cbbc0285419d525124831db026ed34dc8207ef - Sigstore transparency entry: 2154324135
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitoxide-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: gitoxide-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f37e8c0d42f250c1fdff29e0248518a48bf46812f112cb394edaf1d6a8ad6f1
|
|
| MD5 |
4bcf1f8f36f9aab31b2f9ad571d0b858
|
|
| BLAKE2b-256 |
dc8a3cecc98ed8522c7ac0ed4dcddaea7fef6c9b5308edaa26c97bdd06ffb7bd
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
6f37e8c0d42f250c1fdff29e0248518a48bf46812f112cb394edaf1d6a8ad6f1 - Sigstore transparency entry: 2154323361
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitoxide-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: gitoxide-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f561ce5d8ddb5b7d49bd08af4a2e3502cf14b1c26660dd57eca4a1e237e0e450
|
|
| MD5 |
34647305df1045a9e876621d5c0d2cfc
|
|
| BLAKE2b-256 |
8975e0c92827f8d95fe941a0587179446dca561af72de1dad16239069e1e14b2
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
f561ce5d8ddb5b7d49bd08af4a2e3502cf14b1c26660dd57eca4a1e237e0e450 - Sigstore transparency entry: 2154323158
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitoxide-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: gitoxide-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9138c1334a8cc942c485746bd69cefbc3fd10552b3161fae30221fed9b6b997f
|
|
| MD5 |
a710d450f3e23af8634d7335d1452cc4
|
|
| BLAKE2b-256 |
a6ada4cea46f18dbf33c008e65bc7a7cbd6a84dab5ee018c5d82a3fbc8028f92
|
Provenance
The following attestation bundles were made for gitoxide-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on shenxianpeng/gitoxide
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitoxide-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
9138c1334a8cc942c485746bd69cefbc3fd10552b3161fae30221fed9b6b997f - Sigstore transparency entry: 2154323832
- Sigstore integration time:
-
Permalink:
shenxianpeng/gitoxide@295428ed88e4258b17cbd450361b1c31e56bbffb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shenxianpeng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@295428ed88e4258b17cbd450361b1c31e56bbffb -
Trigger Event:
push
-
Statement type: