Skip to main content

Rust-powered filesystem toolkit: fast walk, parallel hashing, bulk copy, file watching, and deduplication.

Project description

pyfs_watcher

Rust-powered filesystem toolkit for Python. Fast recursive directory listing, parallel file hashing, bulk copy/move with progress, cross-platform file watching, and file deduplication.

Install

pip install pyfs_watcher

From source:

pip install maturin
maturin develop

Usage

Walk directories (parallel, faster than os.walk)

import pyfs_watcher

# Streaming iterator
for entry in pyfs_watcher.walk("/data", file_type="file", glob_pattern="*.py"):
    print(entry.path, entry.file_size)

# Bulk collect (faster when you need all results)
entries = pyfs_watcher.walk_collect("/data", max_depth=3, sort=True, skip_hidden=True)

Hash files (parallel SHA256/BLAKE3)

# Single file
result = pyfs_watcher.hash_file("large.iso", algorithm="blake3")
print(result.hash_hex)

# Parallel batch hashing
results = pyfs_watcher.hash_files(paths, algorithm="blake3", callback=lambda r: print(r.path))

Copy/move with progress

def on_progress(p):
    pct = p.bytes_copied / p.total_bytes * 100
    print(f"{pct:.0f}% - {p.current_file}")

pyfs_watcher.copy_files(sources, "/dest", progress_callback=on_progress)
pyfs_watcher.move_files(sources, "/dest")  # rename if same fs, copy+delete otherwise

Watch for file changes

# Sync
with pyfs_watcher.FileWatcher("/data", debounce_ms=500, ignore_patterns=["*.tmp"]) as w:
    for changes in w:
        for c in changes:
            print(c.path, c.change_type)  # "created", "modified", "deleted"

# Async
async for changes in pyfs_watcher.async_watch("/data"):
    for c in changes:
        print(c.path, c.change_type)

Find duplicate files

groups = pyfs_watcher.find_duplicates(
    ["/photos", "/backup"],
    min_size=1024,
    progress_callback=lambda stage, done, total: print(f"{stage}: {done}/{total}"),
)
for g in groups:
    print(f"{g.file_size}B x {len(g.paths)} copies = {g.wasted_bytes}B wasted")
    for path in g.paths:
        print(f"  {path}")

API

All functions raise typed exceptions inheriting from FsWatcherError:

  • WalkError - directory walk failures
  • HashError - hashing failures
  • CopyError - copy/move failures
  • WatchError - file watching failures

Standard FileNotFoundError and PermissionError are raised for I/O errors.

Development

# Setup
uv venv && source .venv/bin/activate
uv pip install maturin pytest pytest-asyncio pytest-timeout

# Build
maturin develop

# Test
cargo test        # Rust tests
pytest tests/     # Python tests

# Benchmark
python benches/bench_walk.py
python benches/bench_hash.py

Tech

  • Rust + PyO3 for Python bindings
  • jwalk for parallel directory traversal
  • BLAKE3/SHA-256 for hashing with rayon parallelism
  • notify + debouncer for cross-platform file watching
  • Staged dedup pipeline: size grouping -> partial hash -> full hash

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

pyfs_watcher-0.1.1.tar.gz (35.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyfs_watcher-0.1.1-cp39-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

pyfs_watcher-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pyfs_watcher-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (876.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file pyfs_watcher-0.1.1.tar.gz.

File metadata

  • Download URL: pyfs_watcher-0.1.1.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyfs_watcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 66cce31033bfaa1273d60c567736f9b91ecabf2874c8ee8bb7f013d86aa50621
MD5 1e9ea5aecc8629679477f2dea8b7db6f
BLAKE2b-256 9f91f8543374bce111c17ae91471378978dcb68e4196667ac7d2eb89f3c7633b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.1.tar.gz:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfs_watcher-0.1.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyfs_watcher-0.1.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b36c6a5c7e62687957479a9288938cb32c1f775676c67f5bebeae268ee518280
MD5 860329eff87c136ec5877c7dfed8bcbd
BLAKE2b-256 b02da158c64b610976446e13c9448319d532298ae0004e59bf4549a64a1481c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.1-cp39-abi3-win_amd64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfs_watcher-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 07b0200e95c1a902b1b6ff63526370be1029f16df5ad3f029dea4857c7a81354
MD5 e8d02d0a53d93e0a273ee8a9489b33b1
BLAKE2b-256 3afb899c173b472c47190c46bfca1713104abcd9d037f0f53fbd78c6d0a26d8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfs_watcher-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c6e8dd34cc43d07585d6605b68a0091538b16e4f7e7fb3293ee9a326f95b411
MD5 7662818b534bdc6f9ff1d20c4dc340cb
BLAKE2b-256 e0933a25dda32b845d19b7dabcacaffe5cce6db440a03260ba1514ab3ec767f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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