larzwatch
Portable, poll-based file & directory watching. Pure Python, zero dependencies.
Detect when files are created, modified, or deleted, and react. It works by
comparing snapshots of modification times, so it has no native dependencies and
behaves identically on every OS (where watchdog needs platform backends). Run
a blocking loop, a background thread, or - crucially for tests - call poll()
yourself and inspect the changes.
from larzwatch import Watcher
w = Watcher("src", patterns=["*.py"])
w.on_change(lambda c: print(c.type, c.path)) # 'created' / 'modified' / 'deleted'
w.watch(interval=1) # blocking; or w.start() for a background thread
Why
- No native backends.
watchdogis great but ships OS-specific extensions; larzwatch is pure Python and works the same everywhere - handy for CI, weird filesystems, and locked-down environments. Polling is perfectly fine for reload-on-change, build triggers, and config reloading. - Testable.
poll()returns the exact list ofChange(type, path)since the last call, so you unit-test file-change logic without threads or sleeps. - Filtered & recursive.
patterns=["*.py", "*.toml"]andrecursive=True/False. - Zero dependencies.
Install
pip install larzwatch
Usage
from larzwatch import Watcher
w = Watcher("config", patterns=["*.yaml"])
w.on_change(reload_config)
# blocking loop
w.watch(interval=0.5)
# or background + your own loop
w.start(interval=0.5)
...
w.stop()
# or drive it yourself (tests, cron)
for change in w.poll():
print(change.type, change.path)
Tests
python -m unittest discover -s tests -v # 9 tests incl. create/modify/delete + background
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT (c) larz-scripter
Metadata
Release files for larzwatch 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 | |
|---|---|---|---|---|
| larzwatch-0.1.0.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzwatch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / larzwatch-0.1.0.tar.gz
| Download URL | larzwatch-0.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f1b3cde4ed5e5dc586d720136e1a379fb83619817da5d07fef9ed3e63020510
|
|
BLAKE2b-256 checksum How to use checksums |
95895cbaad10abbea00215803443efc5381d085b07f81789b815b8ebcc03adbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzwatch-0.1.0-py3-none-any.whl
| Download URL | larzwatch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06d74d44b5a0e01cd8993d29c700c9b42a00c88ebb8634a3416aff3a449a325e
|
|
BLAKE2b-256 checksum How to use checksums |
e220b4788e5edc2af1a98e7be7a9f86f0ac928c0fbf86d699db900ebb8f8735d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzwatch 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.