Registry / devops / scmrepo

scmrepo

JSON →
library3.6.2pypypi✓ verified 23d ago

scmrepo is an SCM wrapper and fsspec filesystem for Git, commonly used within the DVC ecosystem. It provides a unified API for interacting with Git repositories using various backends like pygit2, dulwich, and gitpython, without necessarily requiring a full `git checkout`. The library is actively maintained, with frequent patch and minor releases.

pip install scmrepo
INSTALL
IMPORT
SIG · SCMREPO
S
scmrepo
devopspythonv3.6.2
Install
7.2s avg
Import
304ms
Disk
78MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.320s · 74.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.2s · import 0.288s · 79MB
78MB installed
● package 78MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GitFileSystem
from scmrepo.fs import GitFileSystem
Git
from scmrepo.git import Git

This quickstart demonstrates how to initialize a Git repository using `scmrepo.git.Git`, commit a file, and then access that file system through `scmrepo.fs.GitFileSystem`.

import os import shutil import tempfile from scmrepo.git import Git from scmrepo.fs import GitFileSystem # Create a temporary directory for the repository repo_dir = tempfile.mkdtemp() file_path = os.path.join(repo_dir, "test_file.txt") try: # Initialize a Git repository git = Git(repo_dir) git.init() # Create and commit a file with open(file_path, "w") as f: f.write("Hello, scmrepo!\n") git.add(file_path) git.commit("Initial commit", allow_empty=True) # Use GitFileSystem to read the file from 'HEAD' fs = GitFileSystem(repo_dir, rev="HEAD") with fs.open("test_file.txt", "r") as f: content = f.read() print(f"Content of test_file.txt: {content.strip()}") # Demonstrate walking the file system print("\nFiles in repo (from GitFileSystem):") for root, dnames, fnames in fs.walk("/"): for dname in dnames: print(fs.path.join(root, dname)) for fname in fnames: print(fs.path.join(root, fname)) except Exception as e: print(f"An error occurred: {e}") finally: # Clean up the temporary directory shutil.rmtree(repo_dir) print(f"Cleaned up temporary repository at {repo_dir}")
Debug
Known issues
gotchascmrepo supports multiple Git backends (dulwich, pygit2, gitpython). To use a specific backend, you must install its corresponding Python package (e.g., `pip install dulwich`) alongside `scmrepo`.
fix
Install the desired backend package: `pip install scmrepo dulwich` or `pip install scmrepo pygit2`.
affects: All versions
breakingFor the `pygit2` backend, the `ls_remotes` method was migrated to `list_heads`, and treating `LsRemoteResult` as a dictionary was deprecated.
fix
Update `pygit2` backend code to use `list_heads` and access `LsRemoteResult` attributes directly instead of treating it as a dictionary.
affects: >=3.5.5
breakingFor the `dulwich` backend, `repo stage` was deprecated in favor of `worktree` for some operations, and the minimum `dulwich` version was bumped to `0.24.3`.
fix
Ensure `dulwich` is at least version `0.24.3` and update code to use `worktree` for affected operations. Additionally, path handling on Windows with `dulwich>=0.25.1` was fixed in `scmrepo 3.6.2`.
affects: >=3.5.4
gotchaThe `dulwich` backend has seen fixes related to GPG signing for commits across several versions. If you encounter issues with signed commits using `dulwich`, check `scmrepo` versions `3.5.7` and `3.5.8` for relevant fixes.
fix
Upgrade to `scmrepo>=3.5.8` for improved GPG signing compatibility with `dulwich`.
affects: 3.5.0 - 3.5.6
Upgrade
Version history
3.6.2latest on PyPI · released Mar 31, 2026
Audit
Dependencies
fsspecrequiredProvides the core GitFileSystem functionality for abstracting Git repositories as a filesystem.
dulwichoptionalOptional backend for Git repository operations, a pure-Python implementation.
pygit2optionalOptional backend for Git repository operations, a C-bindings based implementation.
gitpythonoptionalOptional backend for Git repository operations.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources