No-frills SWHID computation for files and directories
Project description
miniswhid
No-frills Software Hash Identifier (SWHID) computation for files and directories.
Features
- Support for content (
cnt) and directory (dir) SWHIDs - Concurrent file hashing on multi-core systems
- Minimal dependencies — uses only Python standard library
Revision, release and snapshot SWHIDs are not supported.
Requirements
- Python 3.10 or higher
Installation
pip install miniswhid
Quick Start
Command Line
# Compute SWHID for a file
miniswhid README.md
# Output: swh:1:cnt:4c7fdf8...
# Compute SWHID for a directory
miniswhid /path/to/directory
# Output: swh:1:dir:8b137891...
Python API
from miniswhid import compute_content_swhid, compute_directory_swhid
# File content SWHID
file_swhid = compute_content_swhid("README.md")
print(file_swhid) # swh:1:cnt:4c7fdf8...
# Directory SWHID
dir_swhid = compute_directory_swhid("/path/to/directory")
print(dir_swhid) # swh:1:dir:8b137891...
Development
Running Tests
# Install development dependencies
uv sync
# Run test suite
uv run pytest
# Run with coverage
uv run pytest --cov=miniswhid
# Run linting and type checking
uvx ruff check
uvx ruff format
uvx mypy .
# Or run all checks via pre-commit
uv run pre-commit run --all-files
License
MIT - see LICENSE file.
Acknowledgements
This project's test suite uses reference SWHID values generated by the Software Heritage toolchain (swh identify) to ensure correctness and compatibility with the official implementation.
Changelog
0.1.1 (2026-03-14)
- Added Python 3.14 support
- Updated dependencies and tool versions
- Added tests for ThreadPoolExecutor error handling
0.1.0 (2025-08-13)
- Initial release with complete SWHID computation for files and directories
- Command-line interface (
miniswhidcommand) - Python API with
compute_content_swhid()andcompute_directory_swhid() - Parallel processing for directory traversal
- Comprehensive test suite with 22+ tests using official Software Heritage reference values
- Type checking with mypy and strict type annotations
- Code formatting and linting with ruff
- Pre-commit hooks for code quality assurance
- Automated PyPI publishing via GitHub Actions
- TestPyPI workflow for release validation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file miniswhid-0.1.1.tar.gz.
File metadata
- Download URL: miniswhid-0.1.1.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cdf9b971f4b7fa53457f5287aac37e4db4c0660b9fb824b8902dd91d0c512fe
|
|
| MD5 |
2d53098a36375a3c546906cc20f91bc9
|
|
| BLAKE2b-256 |
1265bd65b03d022ed292e5c3593d6144cc5fc6765012329ea20798ec385434a0
|
Provenance
The following attestation bundles were made for miniswhid-0.1.1.tar.gz:
Publisher:
publish.yml on diegojorquera/miniswhid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miniswhid-0.1.1.tar.gz -
Subject digest:
0cdf9b971f4b7fa53457f5287aac37e4db4c0660b9fb824b8902dd91d0c512fe - Sigstore transparency entry: 1106509514
- Sigstore integration time:
-
Permalink:
diegojorquera/miniswhid@f8551135231b0e8392ed31a121f70d16edd28cad -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/diegojorquera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8551135231b0e8392ed31a121f70d16edd28cad -
Trigger Event:
release
-
Statement type:
File details
Details for the file miniswhid-0.1.1-py3-none-any.whl.
File metadata
- Download URL: miniswhid-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19e64037634166fc913b896e1ef7056ec1eba4e06edf58395021a65fbd231c0a
|
|
| MD5 |
3d3a73bab86a707e638bddf98da233b0
|
|
| BLAKE2b-256 |
fc826eeaa10b864ced43e4d14f83a506f2e75f8c3ec85bb296a66f886dfc098d
|
Provenance
The following attestation bundles were made for miniswhid-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on diegojorquera/miniswhid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miniswhid-0.1.1-py3-none-any.whl -
Subject digest:
19e64037634166fc913b896e1ef7056ec1eba4e06edf58395021a65fbd231c0a - Sigstore transparency entry: 1106509583
- Sigstore integration time:
-
Permalink:
diegojorquera/miniswhid@f8551135231b0e8392ed31a121f70d16edd28cad -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/diegojorquera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8551135231b0e8392ed31a121f70d16edd28cad -
Trigger Event:
release
-
Statement type: