repopath
pathlib for the repository trees of GitHub, GitLab, Gitea, Subversion and SourceForge, read-only.
GitHubPath("src/mod.py", owner="acme", repo="widgets", ref="v1.2") has the method
names, signatures and exception types of pathlib.Path, and GitLabPath and GiteaPath
do the same for GitLab and for Gitea and Forgejo (Codeberg); RepoPath is the class that
returns any of them. None needs a URI, and all
build on pathapi alone; with
uripath installed the same package also
provides the repo:, github:, gitlab:, gitea:, svn+https:, svn+http: and sourceforge: schemes. It is documented at
https://jose-pr.github.io/repopath/.
The classes are clients of the hosting services' REST APIs. They speak no git
protocol: there is no clone, no commit and no git: URL, and the tree is read-only.
Features
| Kind | Class | type= |
Detected for | API |
|---|---|---|---|---|
| GitHub and GitHub Enterprise | GitHubPath |
"github" |
github.com |
contents API at api.github.com, or https://<instance>/api/v3 |
| GitLab and self-hosted GitLab | GitLabPath |
"gitlab" |
gitlab.com |
REST API v4 at https://<instance>/api/v4 |
| Gitea, Forgejo and Codeberg | GiteaPath |
"gitea" (alias "forgejo") |
codeberg.org |
REST API at https://<instance>/api/v1 |
| Subversion over HTTP | SVNPath |
"svn" |
(type= and the URL of the repository) |
WebDAV of mod_dav_svn at that URL |
| SourceForge (Subversion tools) | SourceForgePath |
"sourceforge" |
sourceforge.net |
REST API of the site, then the tool's Subversion URL |
- A
pathlibpath in a repository:open,read_text,iterdir,glob,statand the rest, pluswalk,copyout of the tree andPathSynceras a source, frompathapi. Nothing connects until the first request. - One class for the kind:
RepoPath("f", owner="acme", repo="widgets", instance="github.com")is aGitHubPath; another instance needstype=, andRepoPath.kinds()lists the kinds. A kind is a subclass that registers itself. - Cheap listings: a directory is one request and each child carries the size and
type the listing gave, so
walk()andglob()cost one request per directory;stat()of a file is aHEAD. Listings past GitHub's 1,000-entry cap, GitLab's pages and Gitea's pages of 1,000 are read to the end. - Authentication that stays out of sight:
token=is sent as a bearer token to the API's own origin only, and shown by nostr(),repr(), pickle or error message. A token over plainhttp://to another host warns. - No library to install: requests go through
pathapi.http, on the standard library, with a replaceable transport. Errors are theOSErrortypespathlibraises,RateLimitError(aBlockingIOError) for a rate limit andBadReplyErrorfor a reply that is not the shape the API documents. - Subversion and SourceForge:
SVNPath("trunk/README", instance="https://svn.example.org/repos/project")reads a Subversion repository served over HTTP with a request perstat()and per listing, a revision withref=, links and the md5 and sha1 digests the server states;SourceForgePath("README", project="docutils")finds the Subversion tool of a SourceForge project and reads it the same way. - The
repo:,github:,gitlab:,gitea:,svn+https:,svn+http:andsourceforge:schemes foruripath:URIPath("github://github.com/acme/widgets/src/mod.py?ref=v1.2")is aGitHubURIPaththat delegates to aGitHubPath.
Installation
pip install repopath
Requires pathapi, which pip installs with it, and Python 3.9 or newer.
| Install | Adds |
|---|---|
pip install repopath |
the paths and the backends; no other library |
pip install "repopath[uri]" |
uripath and with it the repo:, github:, gitlab:, gitea:, svn+https:, svn+http: and sourceforge: schemes |
pip install "repopath[all]" |
all of the above |
Quick start
A path in a repository: the owner and repository are keywords, the segments are the
path inside it, and ref is a branch, a tag or a commit:
from repopath import GitHubPath
readme = GitHubPath("README.md", owner="psf", repo="requests")
print(readme.read_text()[:200])
for child in readme.parent.iterdir():
print(child.name, child.is_dir())
Another kind, or another instance: instance names the server, type the kind when
the instance does not tell, and token is the credential:
from repopath import GitLabPath, RepoPath
doc = RepoPath("doc", owner="gitlab-org", repo="gitlab", instance="gitlab.com")
private = RepoPath(
"src", owner="team/tools", repo="app", instance="git.example.org",
type="gitlab", token="glpat-...",
)
assert isinstance(doc, GitLabPath)
A Gitea or Forgejo server is a kind of its own; Codeberg is detected, any other host
needs type="gitea" (or its alias "forgejo"):
from repopath import RepoPath
readme = RepoPath("README.md", owner="forgejo", repo="forgejo", instance="codeberg.org")
mine = RepoPath(
"src", owner="me", repo="app", instance="git.example.org", type="gitea",
token="...",
)
Copy a tree out of a repository with pathapi:
from pathapi import LocalPath
from repopath import GitHubPath
GitHubPath("docs", owner="psf", repo="requests", ref="main").copy(
LocalPath("docs-copy"), recursive=True
)
The schemes, with uripath installed:
from uripath import URIPath
print(URIPath("repo://github.com/psf/requests/README.md?ref=main").read_text()[:200])
API overview
| Module | Purpose |
|---|---|
repopath |
RepoPath, GitHubPath, GitLabPath, GiteaPath, SVNPath, SourceForgePath, the backends RepoBackend and BaseRepoBackend, the exceptions RepoPathError, RateLimitError and BadReplyError, the warning InsecureTransportWarning and __version__ |
repopath.exceptions |
The exceptions and the warning |
repopath.uri |
RepoURIPath, GitHubURIPath, GitLabURIPath, SVNURIPath and SourceForgeURIPath, the schemes of uripath (needs the uri extra) |
The full reference is on the documentation site;
an agent-oriented API summary ships inside the package as repopath/AGENTS.md.
Development
pip install -e ".[dev,all]"
python -m pytest -q -rs
The tests send every request to a fake of the API on the loopback interface; none
reaches another host. A test that needs uripath is skipped without it, so check the
skip list (-rs). Contributor notes (virtual environments, formatting, CI, releases) are
in the repository's AGENTS.md.
To preview the documentation: pip install -e ".[all,docs]" then mkdocs serve.
Changes are recorded in the changelog.
Releasing
This project follows Semantic Versioning and keeps a
CHANGELOG.md. Pushing a tag matching v* triggers the release
workflow: test gate → build (checking the tag names the version built) → a strict
docs build as a gate → GitHub release → publish. The release workflow never deploys
the docs site itself: for a final release its last job dispatches the docs workflow
at the tag, which owns every Pages deploy.
License
MIT — see LICENSE.
Metadata
Release files for repopath 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| repopath-0.1.1.tar.gz | 175.1 kB | With provenance | Details for repopath-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| repopath-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for repopath-0.1.1-py3-none-any.whl |
Total release size: 233.8 kB
Release files / repopath-0.1.1.tar.gz
| Download URL | repopath-0.1.1.tar.gz |
|---|---|
| Size | 175.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb8996562c031100a67de50780693183e18c76b06739546d432fec16d6acd4f6
|
|
BLAKE2b-256 checksum How to use checksums |
5f71df3ed07469a51dfa87e5f416cc75cfc1785ba94fadd820209a3d6b42d33a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / repopath-0.1.1-py3-none-any.whl
| Download URL | repopath-0.1.1-py3-none-any.whl |
|---|---|
| Size | 58.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1005bd028bec42a512a1553c89df9e56c04ac047247b4d59940352973540948f
|
|
BLAKE2b-256 checksum How to use checksums |
7996881e8ecd04ad4ee4de2bf9111787bb43e33d915b2a5e5d16687f036d9673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logSecurity for repopath 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for repopath-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logA 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.