Self-sufficient debugging REPL for running Python programs
Project description
devliverepl
Self-sufficient debugging REPL for running Python programs
devliverepl provides an always-on ptpython REPL server accessible via telnet, enabling live inspection and debugging of running Python applications without interrupting execution.
Features
- ๐ Live inspection โ Connect to running programs and inspect state
- ๐ฆ Context capture โ Automatic capture of locals/globals from call site
- ๐ฏ Explicit exposure โ
@exposedecorator to mark important objects - ๐ Debugger integration โ Built-in support for pdb, pudb, ipdb, pdbpp, patdb, webpdb
- ๐จ Rich terminal โ ptpython with syntax highlighting and auto-completion
- ๐ก๏ธ Thread-safe โ Daemon thread doesn't block your application
- ๐ฆ Graceful shutdown โ Clean connection handling with atexit support
Installation
# Basic installation
pip install devliverepl
# With uv
uv add devliverepl
# With optional debugger integrations
pip install devliverepl[debuggers]
uv add devliverepl --extra debuggers
Quick Start
import devliverepl
app_state = {"users": [], "status": "running"}
# Start the REPL - captures app_state
devliverepl.detach()
# Connect from another terminal:
# $ telnet localhost 8022
#
# In the REPL, you can access:
# >>> app_state
# {'users': [], 'status': 'running'}
# >>> app_state['users'].append('test')
Usage
Basic Usage
import devliverepl
# Your application state
config = {"debug": True}
database = Database()
# Start REPL (captures locals)
devliverepl.detach(port=8022)
# ... application runs ...
Exposing Objects
Use the @expose decorator to make objects available across all connections:
import devliverepl
@devliverepl.expose
class Database:
"""Database connection pool."""
def query(self, sql):
return self._execute(sql)
@devliverepl.expose
def get_stats():
"""Get application statistics."""
return stats
devliverepl.detach()
Configuration
import devliverepl
devliverepl.configure(
port=8022,
host="127.0.0.1",
banner="rich", # or "minimal" or "custom"
log_connections=True,
)
devliverepl.detach()
Custom Banner
import devliverepl
import os
devliverepl.set_banner(lambda: f"""
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ MyApp Debugger โ PID {os.getpid()} โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
""")
devliverepl.detach()
REPL Commands
When connected, use % commands:
%ls # List exposed objects and captured variables
%import os # Import a module
%where db # Show where an object was defined
%env # Show captured environment summary
%help # Show all commands
Debugger Integration
# In the REPL, use the debug helper:
debug.attach() # Auto-detect best debugger
debug.pudb() # Use PuDB
debug.ipdb() # Use IPython debugger
debug.pdbpp() # Use pdb++
debug.patdb() # Use PatDB (pattern debugger)
debug.web() # Use Web-PDB (browser UI)
debug.list_available() # Show installed debuggers
Shutdown
import devliverepl
# Graceful shutdown (waits for connections to close)
devliverepl.shutdown()
# Immediate shutdown
devliverepl.shutdown(force=True)
Examples
See the examples/ directory for more:
basic_usage.pyโ Simple long-running scriptflask_app.pyโ Flask web server integrationdata_pipeline.pyโ Data processing pipeline
How It Works
- Call
devliverepl.detach()in your code - The function captures the calling frame's
locals()andglobals() - A ptpython REPL server starts in a daemon thread
- Connect via telnet to inspect the captured state
- Disconnect anytime without stopping your application
Architecture
devliverepl/
โโโ __init__.py # Public API: detach(), shutdown(), @expose
โโโ core.py # REPLServer, event loop management
โโโ capture.py # Frame capture, context extraction
โโโ registry.py # Exposed object registry
โโโ banner.py # Banner generation
โโโ commands.py # % commands implementation
โโโ shutdown.py # Graceful shutdown handling
โโโ integrations/ # Debugger integrations
โโโ pdb.py
โโโ pudb.py
โโโ ipdb.py
โโโ ...
Requirements
- Python 3.10+
- ptpython >= 3.0.0
- prompt-toolkit >= 3.0.0
Optional (for debugger integrations):
- pudb >= 2022.1
- ipdb >= 0.13.0
- pdbpp >= 0.10.0
- web-pdb >= 0.5.0
Roadmap
v0.2.0 (Current)
- โ Multiple named REPLs (foundational support)
- โ Enhanced configuration system
- โ Full debugger integration suite
v0.3.0 (Planned)
- โณ Thread-aware stack inspection
- โณ Context manager pattern
- โณ SSH support
- โณ Authentication
- โณ TLS/SSL
- โณ Multi-client collaboration
Contributing
Contributions welcome! Please read our contributing guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development
# Clone the repository
git clone https://github.com/devliverepl/devliverepl.git
cd devliverepl
# Install in development mode
uv sync --extra dev
# Run tests
pytest
# Run type checking
mypy devliverepl/
# Run linting
ruff check devliverepl/
License
MIT License โ see LICENSE for details.
Acknowledgments
Built with:
- ptpython โ Python REPL
- prompt_toolkit โ Terminal UI
- uv โ Python package manager
Happy debugging! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devliverepl-0.2.0.tar.gz.
File metadata
- Download URL: devliverepl-0.2.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dd00de98d95d3e04bb4b5f1cc045239ec985cd5536c896b7d2163dc95a435aa
|
|
| MD5 |
28520aa14004625d9f3b1989249a358a
|
|
| BLAKE2b-256 |
0ed28c77a543c06b7ef398e527646234fa2314c8c21d8c7f88d319f4bd0e8a7c
|
Provenance
The following attestation bundles were made for devliverepl-0.2.0.tar.gz:
Publisher:
release.yml on fkr-0/devliverepl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devliverepl-0.2.0.tar.gz -
Subject digest:
3dd00de98d95d3e04bb4b5f1cc045239ec985cd5536c896b7d2163dc95a435aa - Sigstore transparency entry: 1093930473
- Sigstore integration time:
-
Permalink:
fkr-0/devliverepl@e879937693551e96a76319c7e92266b5fe85ed40 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/fkr-0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e879937693551e96a76319c7e92266b5fe85ed40 -
Trigger Event:
push
-
Statement type:
File details
Details for the file devliverepl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: devliverepl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc10808006b67ec278157b673f3c8ac50ef28e6023f75a1615ecc8e752d0b3a3
|
|
| MD5 |
2ea2b613ffa738ce3a1703aa82c1dba2
|
|
| BLAKE2b-256 |
c2e4be7bf476d4d243270330a4440aa36fff9794252d6164981c605d5050d8dc
|
Provenance
The following attestation bundles were made for devliverepl-0.2.0-py3-none-any.whl:
Publisher:
release.yml on fkr-0/devliverepl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devliverepl-0.2.0-py3-none-any.whl -
Subject digest:
dc10808006b67ec278157b673f3c8ac50ef28e6023f75a1615ecc8e752d0b3a3 - Sigstore transparency entry: 1093930486
- Sigstore integration time:
-
Permalink:
fkr-0/devliverepl@e879937693551e96a76319c7e92266b5fe85ed40 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/fkr-0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e879937693551e96a76319c7e92266b5fe85ed40 -
Trigger Event:
push
-
Statement type: