dirsync is an advanced Python library and command-line tool for synchronizing directory trees. It is based on Anand B Pillai's Python robocopier and provides functionalities like reporting differences, syncing content, and updating existing content with various options for filtering and behavior. The current version is 2.2.6, and it appears to have a stable, though infrequent, release cadence.
Install & Compatibility
Where this runs
tested against v2.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.051s · 17.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.5s · import 0.044s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `sync` function to synchronize files from a source directory to a target directory. It includes creating dummy directories and files, performing a 'sync' operation with verbose output and target directory creation, and finally cleaning up.
import os
from dirsync import sync
# Create dummy source and target directories for demonstration
source_dir = './source_data'
target_dir = './target_data'
os.makedirs(source_dir, exist_ok=True)
os.makedirs(target_dir, exist_ok=True)
with open(os.path.join(source_dir, 'file1.txt'), 'w') as f:
f.write('Hello from source!')
with open(os.path.join(source_dir, 'file2.log'), 'w') as f:
f.write('Log content.')
print(f"Synchronizing from '{source_dir}' to '{target_dir}'")
# Sync: copies all files from source to target, creating target if it doesn't exist
sync(source_dir, target_dir, 'sync', verbose=True, create=True)
print(f"Content of '{target_dir}': {os.listdir(target_dir)}")
# Clean up (optional)
os.remove(os.path.join(source_dir, 'file1.txt'))
os.remove(os.path.join(source_dir, 'file2.log'))
os.rmdir(source_dir)
os.remove(os.path.join(target_dir, 'file1.txt'))
os.remove(os.path.join(target_dir, 'file2.log'))
os.rmdir(target_dir)
dirsync --version
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.