Skip to main content

rusty-git

GitLab CI PyPI version License: Apache 2.0

High-speed pure Rust Git engine (gix + git2) compiled via PyO3 with both native async (Tokio) and GIL-released sync APIs.

rusty-git provides in-process Git operations with zero OS subprocess forks and statically-compiled native wheels (no dynamic libgit2.so dependencies required).


Why rusty-git?

Feature GitPython pygit2 rusty-git
Execution Model Subprocess fork (/usr/bin/git) C library bindings In-process pure Rust + PyO3
GIL Behavior Stalls Python thread during fork Often holds GIL Releases GIL on both sync & async
Async / Tokio ❌ No ❌ No ✅ Native asyncio.Future via Tokio
Installation Pure Python (requires OS git) Requires libgit2.so & C compiler Self-contained precompiled wheel
Smart-HTTP Wire Protocol ❌ No ❌ Partial ✅ In-process Smart-HTTP negotiation

Installation

pip install rusty-git
# or with uv:
uv add rusty-git

Dual-Color Usage: Async & Sync

1. Asynchronous API (Default - for Litestar, FastAPI, Granian, Uvicorn)

All blocking Git I/O is offloaded to a Tokio multi-threaded worker pool, releasing the Python GIL:

import asyncio
import rusty_git


async def main():
    # 1. Initialize a bare repository
    repo_path = await rusty_git.init_bare_repository("/srv/repos/myorg/backend.git")

    # 2. Inspect commits
    commit = await rusty_git.get_commit(repo_path, "HEAD")
    print(commit["sha"], commit["message"], commit["author_name"])

    # 3. Read tree blobs without disk checkout
    readme = await rusty_git.get_tree_blob(repo_path, "main", "README.md")
    print(readme.decode("utf-8"))

    # 4. Fast unified diffs
    hunks = await rusty_git.compare_refs(repo_path, "main~1", "main")
    for hunk in hunks:
        print(hunk["new_path"], hunk["content"])

    # 5. 3-Way Merge
    result = await rusty_git.execute_merge(
        repo_path,
        base_ref="main",
        head_ref="feature",
        author_name="Automated Merge",
        author_email="bot@example.com",
    )
    if result["status"] == "merged":
        print("Merged Commit SHA:", result["commit_sha"])


asyncio.run(main())

2. Synchronous API (rusty_git.sync - for CLI tools, Celery, scripts)

Direct execution on the calling thread with the Python GIL cleanly released (py.detach):

import rusty_git

# Read commit synchronously
commit = rusty_git.sync.get_commit("/path/to/repo.git", "HEAD")
print(commit["sha"], commit["author_name"])

# List branches synchronously
branches = rusty_git.sync.list_branches("/path/to/repo.git")
print("Branches:", branches)

# Read file directly from commit tree
blob = rusty_git.sync.get_tree_blob("/path/to/repo.git", "HEAD", "pyproject.toml")

# 3-Way Merge synchronously
result = rusty_git.sync.execute_merge(
    "/path/to/repo.git",
    "main",
    "feature",
    author_name="Merge Bot",
    author_email="bot@example.com",
)

Smart-HTTP Protocol Wire Support

rusty-git can drive Git HTTP and SSH protocol negotiation completely in-process:

import rusty_git

# Ref advertisement for git-upload-pack (git clone / fetch)
advert = await rusty_git.advertise("/srv/repos/myorg/backend.git", "git-upload-pack")

# Handle pack negotiation and streaming
upload_res = await rusty_git.upload_pack("/srv/repos/myorg/backend.git", request_body)

# Ingest inbound git push packfile atomically
push_res = await rusty_git.receive_pack("/srv/repos/myorg/backend.git", push_body)
print("Updated Refs:", push_res["updated_refs"])

Development & Testing

Rust Tests

cargo test

Python Integration Tests

uv run pytest

License

Apache-2.0 © Framework M Contributors

Metadata

Release files for rusty-git 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rusty-git 0.2.1
File Size Uploaded Provenance Actions
rusty_git-0.2.1.tar.gz 62.3 kB Without provenance Details for rusty_git-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rusty-git 0.2.1
File Actions
rusty_git-0.2.1-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for rusty_git-0.2.1-cp312-abi3-musllinux_1_2_x86_64.whl
rusty_git-0.2.1-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for rusty_git-0.2.1-cp312-abi3-musllinux_1_2_aarch64.whl
rusty_git-0.2.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for rusty_git-0.2.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
rusty_git-0.2.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for rusty_git-0.2.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
rusty_git-0.2.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for rusty_git-0.2.1-cp312-abi3-macosx_11_0_arm64.whl
rusty_git-0.2.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for rusty_git-0.2.1-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 15.1 MB

Release files / rusty_git-0.2.1.tar.gz

Download URL rusty_git-0.2.1.tar.gz
Size 62.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ddc52cc30f6a9e0a03d87cfa4edb02afc520a8334072e5c20a222853fc806b39
BLAKE2b-256 checksum
How to use checksums
8a9a8e700c61f65bb6b72b3972e0f6c885ae41949023656f63f4fdbbcf9210c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL rusty_git-0.2.1-cp312-abi3-musllinux_1_2_x86_64.whl
Size 2.6 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
22feba4111f5d55c3e654e43a4fd70c2a08f60fc4b75b629fa407f83ad1b9add
BLAKE2b-256 checksum
How to use checksums
6bab250976e6806ba12fde4ea22c0a6dca200d97e42cf95cb39017ce8415d534
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL rusty_git-0.2.1-cp312-abi3-musllinux_1_2_aarch64.whl
Size 2.4 MB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
a029626bc8fcce0f16cd39ad64b5ff703dbfc7d1f7f6529850374fc8acc620db
BLAKE2b-256 checksum
How to use checksums
1e588d124c4b7b49a64915f38838d0704c8cdd9b98314c272c81c2ead0728df0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL rusty_git-0.2.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.5 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
15cafddb9ded2d839bb45e6a2d705ebdbf59494c3bd5efa0e543ec9b4811c357
BLAKE2b-256 checksum
How to use checksums
0bb419be7dd335fd15f47433b7e7a28da3b3c479cc39ebea7e7efd817a7f1be7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL rusty_git-0.2.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.4 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a4fad930d8f22ef7fb300827dd455f3860507a30e2d7b609cb8efd01695449cd
BLAKE2b-256 checksum
How to use checksums
0bb96ccfc95c28198fb4829eedafb44f364d700f8ac349bb6cf93f7212f0ec06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL rusty_git-0.2.1-cp312-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b605f7c909934ab5db653ce1869ef3912eab38707826ada82349a6695a53e5cd
BLAKE2b-256 checksum
How to use checksums
2cb47c2ddccb7a41cc938fe27bddb79d850912ca20b31631a3614f88d3ef6752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / rusty_git-0.2.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL rusty_git-0.2.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 2.6 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e5976628422e1e213639f153e2eebb23106f677eb4e7a10a0eceaf5ff0da6fab
BLAKE2b-256 checksum
How to use checksums
b5b39b4b9601f4992c4ef9bdad6be973cab0e61e183cc163b1d55d2f4552af60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Security for rusty-git 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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