Registry / data / checksumdir

checksumdir

JSON →
library1.3.0pypypi✓ verified 24d ago

Checksumdir is a Python library designed to compute a single cryptographic hash for the contents of a given directory. It primarily focuses on the file contents, ignoring metadata by default. The current version is 1.3.0 and it maintains a sporadic or infrequent release cadence, with the latest PyPI release dated August 15, 2025.

pip install checksumdir
INSTALL
IMPORT
SIG · CHECKSUMDIR
C
checksumdir
datapythonv1.3.0
Install
1.5s avg
Import
109ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.0 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.116s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.102s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dirhash
from checksumdir import dirhash

This example demonstrates how to compute MD5 and SHA1 hashes for a directory. It shows the default behavior of hashing only file contents and how to include filenames in the hash calculation. It also includes an example of excluding files by extension. The example uses a temporary directory for a self-contained demonstration.

import checksumdir import os import tempfile # Create a temporary directory and some files for demonstration with tempfile.TemporaryDirectory() as tmpdir: print(f"Created temporary directory: {tmpdir}") os.makedirs(os.path.join(tmpdir, 'subdir'), exist_ok=True) with open(os.path.join(tmpdir, 'file1.txt'), 'w') as f: f.write('content one') with open(os.path.join(tmpdir, 'subdir', 'file2.txt'), 'w') as f: f.write('content two') # Calculate MD5 hash of the directory contents (default ignores filenames/paths) md5_hash = checksumdir.dirhash(tmpdir, 'md5') print(f"MD5 hash (content only): {md5_hash}") # Calculate SHA1 hash, including filenames in the hash calculation sha1_hash_with_names = checksumdir.dirhash(tmpdir, 'sha1', hash_filename=True) print(f"SHA1 hash (including filenames): {sha1_hash_with_names}") # Example with exclusion with open(os.path.join(tmpdir, 'temp_log.log'), 'w') as f: f.write('temporary log content') # Calculate MD5, excluding files ending with .log md5_hash_excluded = checksumdir.dirhash(tmpdir, 'md5', excluded_extensions=['.log']) print(f"MD5 hash (excluding .log files): {md5_hash_excluded}") # The temporary directory is automatically cleaned up here
checksumdir --version
Debug
Known issues
gotchaBy default, `dirhash` computes a hash based *only* on the contents of the files within a directory, ignoring file names, directory structure, and metadata like timestamps. This means renaming a file or moving it to a subdirectory will not change the hash if its content remains the same.
fix
To include filenames or file paths in the hash calculation, use the `hash_filename=True` or `hash_filepath=True` arguments, introduced in version 1.2.0.
affects: All versions
gotchaCalling `checksumdir.dirhash()` with a path to a directory that does not exist will raise a `FileNotFoundError`.
fix
Ensure the directory exists before attempting to hash it, e.g., by checking `os.path.isdir(directory_path)`.
affects: All versions
gotchaHashing very large directories or directories with a vast number of small files can be I/O and CPU intensive, potentially leading to slow performance. Consider the scale of directories being hashed in performance-critical applications.
fix
For extremely large datasets, consider hashing only critical subsets, or implement caching mechanisms for hashes that change infrequently. The `dirhash` library (a similar tool) supports multiprocessing for speedup if applicable.
affects: All versions
breakingChecksumdir version 1.3.0 and later explicitly requires Python 3.9 or newer. Users on older Python versions (e.g., Python 3.8 or earlier) must use an older version of the library or upgrade their Python environment.
fix
Upgrade your Python interpreter to version 3.9 or newer, or pin `checksumdir` to a compatible earlier version (e.g., `pip install 'checksumdir<1.3.0'`).
affects: >=1.3.0
Errors
Common errors & fixes
FileNotFoundError
The directory path provided to `checksumdir.dirhash()` does not exist on the filesystem.
fix
Ensure the target directory exists before calling `checksumdir.dirhash()`, e.g., by checking `os.path.isdir(directory_path)` or creating it if intended.
ModuleNotFoundError: No module named 'checksumdir'
The `checksumdir` library is not installed in the Python environment where the script is being executed, or it's not correctly included in a packaged application.
fix
Install the library using pip: `pip install checksumdir`. If packaging with tools like PyInstaller, ensure the module is properly bundled.
PermissionError: [Errno 13] Permission denied
The Python script lacks the necessary read permissions for one or more files or directories that `checksumdir` attempts to access, or a file is locked by another process (common on Windows).
fix
Grant the user running the script appropriate read permissions for the target directory and its contents. On Windows, ensure no other applications are holding locks on the files.
Hashing very large directories or directories with a vast number of small files can be I/O and CPU intensive, potentially leading to slow performance.
The process of reading and hashing many files, especially in very large directories, consumes significant I/O and CPU resources.
fix
For extremely large datasets, consider hashing only critical subsets, implement caching for unchanging hashes, or explore external tools that support multiprocessing for directory hashing.
The calculated hash does not change when files are renamed or moved within the directory structure.
`checksumdir.dirhash()` by default computes a hash based *only* on the contents of the files, ignoring file names, directory structure, and metadata like timestamps.
fix
To include filenames or file paths in the hash calculation, use the `hash_filename=True` or `hash_filepath=True` arguments in the `dirhash` function.
Upgrade
Version history
1.3.0latest on PyPI · released Aug 15, 2025
Audit
Dependencies
pythonrequiredRequired Python version for compatibility.
Agent activity
24 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
checksumdir — pip install checksumdir · libregistry