Skip to main content

Simple, modern and high performance file watching and code reload in python.

Project description

watchfiles

CI Coverage pypi license

Simple, modern and high performance file watching and code reload in python.


Documentation: watchfiles.helpmanual.io

Source Code: github.com/samuelcolvin/watchfiles


Underlying file system notifications are handled by the Notify rust library.

This package was previously named "watchgod", see the migration guide for more information.

Installation

watchfiles requires Python 3.7 - 3.10.

pip install watchfiles

Binaries are available for:

  • Linux: x86_64, aarch64, i686, armv7l, musl-x86_64 & musl-aarch64
  • MacOS: x86_64 & arm64 (except python 3.7)
  • Windows: amd64 & win32

Otherwise, you can install from source which requires Rust stable to be installed.

Usage

Here are some examples of what watchfiles can do:

watch Usage

from watchfiles import watch

for changes in watch('./path/to/dir'):
    print(changes)

See watch docs for more details.

awatch Usage

import asyncio
from watchfiles import awatch

async def main():
    async for changes in awatch('/path/to/dir'):
        print(changes)

asyncio.run(main())

See awatch docs for more details.

run_process Usage

from watchfiles import run_process

def foobar(a, b, c):
    ...

if __name__ == '__main__':
    run_process('./path/to/dir', target=foobar, args=(1, 2, 3))

See run_process docs for more details.

arun_process Usage

import asyncio
from watchfiles import arun_process

def foobar(a, b, c):
    ...

async def main():
    await arun_process('./path/to/dir', target=foobar, args=(1, 2, 3))

if __name__ == '__main__':
    asyncio.run(main())

See arun_process docs for more details.

CLI

watchfiles also comes with a CLI for running and reloading code. To run some command when files in src change:

watchfiles "some command" src

For more information, see the CLI docs.

Or run

watchfiles --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watchfiles-0.15.0.tar.gz (36.2 kB view hashes)

Uploaded Source

Built Distributions

watchfiles-0.15.0-cp37-abi3-win_arm64.whl (246.2 kB view hashes)

Uploaded CPython 3.7+ Windows ARM64

watchfiles-0.15.0-cp37-abi3-win_amd64.whl (253.0 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

watchfiles-0.15.0-cp37-abi3-win32.whl (246.3 kB view hashes)

Uploaded CPython 3.7+ Windows x86

watchfiles-0.15.0-cp37-abi3-musllinux_1_1_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.1+ x86-64

watchfiles-0.15.0-cp37-abi3-musllinux_1_1_aarch64.whl (1.3 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.1+ ARM64

watchfiles-0.15.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

watchfiles-0.15.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

watchfiles-0.15.0-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.12+ x86-64

watchfiles-0.15.0-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.12+ i686

watchfiles-0.15.0-cp37-abi3-macosx_11_0_arm64.whl (357.6 kB view hashes)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

watchfiles-0.15.0-cp37-abi3-macosx_10_7_x86_64.whl (368.0 kB view hashes)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page