Skip to main content

Cross-platform Git history access via Rust with a Python API

Project description

PyGitX icon

pypi coverage support-version license build commit

Cross-platform Git history access implemented in Rust with a Python API via PyO3 and libgit2.

Highlights

  • Fast Git history access via libgit2 with a lightweight Python wrapper.
  • Repo helpers for HEAD info, revision parsing, commit listing, and branch/tag lookup.
  • History rewriting tools: amend messages, rewrite author/committer, reword arbitrary commits, squash, rebase (pick-only), drop commits, and purge paths.
  • All rewrites return a RewriteResult with mappings and ref updates.

Install

pip install pygitx

Python usage

import pygitx
from pathlib import Path

repo = pygitx.open_repo(Path("."))
head = repo.head()
print("HEAD:", head.id if head else "None")

# Resolve a revision (branch/tag/oid) to a hex id
print("main ->", repo.rev_parse("main"))

for c in repo.list_commits(max=5):
    print(f"{c.id[:7]} {c.author} <{c.email}> {c.summary}")

# Quick repo summary (also printed by str(repo))
print(repo.summary())

# Graph helpers
print("Branches:", repo.list_branches(local=True, remote=False))
print("Tags:", repo.list_tags())
print("Current branch:", repo.current_branch())
print("Merge base of main and feature:", repo.merge_base("main", "feature"))
print("Ahead/behind main vs feature:", repo.ahead_behind("main", "feature"))
print("Diff HEAD~1..HEAD:", repo.diff_stat("HEAD~1", "HEAD").files_changed, "files")

Example script: examples/demo.py (run with --help to see options).

Documentation

Full API and usage docs live in docs/ (Sphinx). Build locally with:

make docs

Or browse the published docs if available in your environment.

Development

  • Run Rust and Python checks: make test
  • Pytest for Python wrappers: pytest
  • Make targets: make venv, make install, make develop, make release, make docs, make test
  • Optional pre-commit prompt: set git config core.hooksPath .githooks and chmod +x .githooks/pre-commit to be prompted to run make develop, make test, and pytest before each commit.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pygitx-0.2.1-cp39-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl (1.5 MB view details)

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

pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file pygitx-0.2.1-cp39-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for pygitx-0.2.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0cc93fc9fed6b73c5be7cad3efeec52310f83d5543677855bb94d7f6b407aba9
MD5 000d2263630aa3bfcbc69eda4c7b8762
BLAKE2b-256 1ec3eea40ef5836aaabf471aaef10285dc5ddb27516d55e1e2aec6422c87d006

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-win_amd64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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

File details

Details for the file pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 728565abe86ac5ad8dac4056e585a0c05df372ccb611a8aa904ccab202a9328d
MD5 6458fd677b12d54eed0f45f105dd3245
BLAKE2b-256 700394227f2d8bcff74740fd21c63ad6efef30ca135c343553e951152d6f427f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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

File details

Details for the file pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 278bb98cd2f0105f1543fc2a47133ea3405a8e5e3bfce6d08b39958f453ade4c
MD5 98de59c6e7cd633f15018971bf0601d6
BLAKE2b-256 a26aec7ea3877135e332a7ca7e427893ef7105f146f161919ff30cee2f36324a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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