Skip to main content

No-frills SWHID computation for files and directories

Project description

miniswhid

No-frills Software Hash Identifier (SWHID) computation for files and directories.

PyPI version Python versions License: MIT

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 (miniswhid command)
  • Python API with compute_content_swhid() and compute_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


Download files

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

Source Distribution

miniswhid-0.1.1.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

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

miniswhid-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for miniswhid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0cdf9b971f4b7fa53457f5287aac37e4db4c0660b9fb824b8902dd91d0c512fe
MD5 2d53098a36375a3c546906cc20f91bc9
BLAKE2b-256 1265bd65b03d022ed292e5c3593d6144cc5fc6765012329ea20798ec385434a0

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on diegojorquera/miniswhid

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

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

Hashes for miniswhid-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19e64037634166fc913b896e1ef7056ec1eba4e06edf58395021a65fbd231c0a
MD5 3d3a73bab86a707e638bddf98da233b0
BLAKE2b-256 fc826eeaa10b864ced43e4d14f83a506f2e75f8c3ec85bb296a66f886dfc098d

See more details on using hashes here.

Provenance

The following attestation bundles were made for miniswhid-0.1.1-py3-none-any.whl:

Publisher: publish.yml on diegojorquera/miniswhid

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