Simple Reload
Simple library to automatically restart Python scripts on source changes
A lightweight utility that monitors Python files for changes and automatically restarts your script when changes are detected. Perfect for development workflows where you want to see immediate results without manually restarting your application.
import mymodule
from simple_reload import run_simple_reload
def main():
run_simple_reload([mymodule])
print('Hello, running my CLI.')
# Main logic
from time import sleep
try:
while True: sleep(1)
except KeyboardInterrupt:
print('Exiting program (potentially due to file change)')
if __name__ == "__main__":
main()
Installation
pip install simple-reload
Detailed Usage
run_simple_reload takes two main parameters:
modules: A list of modules to watch for changes. The function will monitor all Python files in the directories containing these modules.on_change: Optional callback function that gets called when files change. It receives a set of tuples with the change type and file path.
You can conditionally call run_simple_reload if you'd like to only enable it in debug mode. You can also the auto-reload feature by setting the environment variable SIMPLE_RELOAD_DISABLE=1.
Detailed example:
import myapp
from simple_reload import run_simple_reload, Change
from contextlib import suppress
def main():
if myapp.is_debug_enabled():
run_simple_reload([myapp], on_change=print)
with supress(KeyboardInterrupt):
myapp.start()
if __name__ == "__main__":
main()
When a file changes, the child process is cleanly shutdown (via SIGINT) and a new child is spawned with the same command line arguments that were used to start it originally.
Development
Simple Reload uses Rye for dependency management and the development workflow. To get started with development, ensure you have Rye installed and then clone the repository and set up the environment:
git clone https://github.com/MatthewScholefield/simple-reload.git
cd simple-reload
rye sync
rye run pre-commit install
# Run tests
rye test
Metadata
Release files for simple-reload 0.1.0
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 |
|---|---|---|---|---|
| simple_reload-0.1.0.tar.gz | 4.9 kB | Without provenance | Details for simple_reload-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_reload-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for simple_reload-0.1.0-py3-none-any.whl |
Total release size: 8.7 kB
Release files / simple_reload-0.1.0.tar.gz
| Download URL | simple_reload-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1c0068957596c4cca9073b062d93c28ffb9684ed97e2709175fce34d9b98b41
|
|
BLAKE2b-256 checksum How to use checksums |
f7447e00191e7768b136bd787de5a0fa1637fba2fef651be94ccc87308cc896b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Release files / simple_reload-0.1.0-py3-none-any.whl
| Download URL | simple_reload-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02f092287aeb4332e89ada336503e97aff5fe97601ad105bf61500230afb902a
|
|
BLAKE2b-256 checksum How to use checksums |
747f7853d26f74453077ad68722ede068a314e6f26669bea2d6480277ab7e3ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Security for simple-reload 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.