Registry / http-networking / python-ripgrep

python-ripgrep

JSON →
library0.0.9pypypi✓ verified 85d ago

python-ripgrep is a Python wrapper for the high-performance ripgrep command-line utility. It provides a programmatic interface to run ripgrep searches, parse results, and interact with its various options. Currently at version 0.0.9, its release cadence is irregular, with updates typically occurring to add new features or align with upstream ripgrep changes.

pip install python-ripgrep
INSTALL
IMPORT
SIG · PYTHON-RIPGREP
P
python-ripgrep
http-networkingpythonv0.0.9
Install
1.6s avg
Import
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.9 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 23MB
21MB installed
● package 21MB
Code
Verified usage

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

search
from python_ripgrep import search
from python_ripgrep import Ripgrep
files
from python_ripgrep import files
PySortMode
from python_ripgrep import PySortMode

This quickstart demonstrates how to initialize the Ripgrep wrapper and perform a basic case-insensitive search for a term in text files. It includes setup for a dummy file and error handling for the missing `ripgrep` executable.

import os from python_ripgrep import Ripgrep # Ensure ripgrep is installed and in your PATH. # For example: # Debian/Ubuntu: sudo apt install ripgrep # macOS (Homebrew): brew install ripgrep # Rust cargo: cargo install ripgrep # Create a dummy file for searching if it doesn't exist if not os.path.exists("example_rg.txt"): with open("example_rg.txt", "w") as f: f.write("Hello, World!\n") f.write("This is a test line.\n") f.write("Another line with 'World'.\n") f.write("hello world again.\n") try: # Initialize Ripgrep instance, searching in the current directory # You can also specify a different path: rg = Ripgrep(path='/path/to/project') rg = Ripgrep(path='.') # Perform a case-insensitive search for "world" in .txt files # The search method returns an iterator over results print("Searching for 'world' (case-insensitive) in .txt files:") results = rg.search('world', file_type='.txt', ignorecase=True) found_results = False for result in results: found_results = True print(f"File: {result.file}, Line: {result.line_number}, Match: '{result.match}'") if not found_results: print("No results found.") except FileNotFoundError as e: if "No such file or directory: 'rg'" in str(e): print("\nERROR: ripgrep executable 'rg' not found in your PATH.") print("Please install ripgrep from: https://github.com/BurntSushi/ripgrep#installation") else: print(f"\nAn unexpected FileNotFoundError occurred: {e}") except Exception as e: print(f"\nAn error occurred: {e}") finally: # Clean up the dummy file if os.path.exists("example_rg.txt"): os.remove("example_rg.txt")
Debug
Known issues
gotchaThe `python-ripgrep` library is merely a wrapper; it does not bundle the `ripgrep` executable. `ripgrep` must be installed separately on your system and available in the system's PATH.
fix
Ensure `ripgrep` is installed (e.g., `sudo apt install ripgrep`, `brew install ripgrep`, or `cargo install ripgrep`) and its executable (`rg`) is accessible from your system's PATH.
affects: All versions
gotchaAs a pre-1.0 library (0.0.x), the API of `python-ripgrep` may undergo breaking changes in minor versions without explicit deprecation warnings.
fix
When updating, always review the GitHub repository's changelog or commit history for any API changes. Pin your dependency to a specific `0.0.x` version if stability is critical.
affects: <1.0.0
gotchaFor very large search results, loading all results into memory at once can consume significant resources. The `search` method returns an iterator.
fix
Process `results` iteratively using a `for` loop to avoid loading all matches into memory simultaneously. If you need to paginate or limit results, consider implementing logic around the iterator or using `ripgrep`'s inherent `--max-count` option via the wrapper.
affects: All versions
Upgrade
Version history
0.0.9latest on PyPI · released Jul 30, 2025
Audit
Dependencies
ripgrep (executable)requiredThe library is a wrapper around the ripgrep CLI tool, which must be installed separately and available in the system's PATH.
Agent activity
24 hits · last 30 days
node
22
Resources
python-ripgrep — pip install python-ripgrep · libregistry