Clean-room Python EPUB conformance checker driven by EPUBCheck behavior specs
Project description
pyepubcheck
pyepubcheck is a clean-room Python EPUB validation project driven by the imported EPUBCheck behavior specifications in specs/behavior/features.
The package intentionally uses a flat layout: importable code lives in ./pyepubcheck, not in ./src.
Status:
0.1.0alpha. The project is suitable for validating the behavior covered by its current test suite and SpecMason mappings. It is not yet a complete drop-in replacement for the Java EPUBCheck distribution.
Features
- CLI command named
pyepubcheck. - Validation of expanded EPUB directories and individual OPF, XHTML, SVG, navigation, CSS, NCX, and media overlay resources.
- EPUB 2 and EPUB 3 behavior coverage derived from Gherkin scenarios.
- Optional profile checks for dictionaries, EDUPUB, indexes, previews, accessibility, and related profile constraints.
- Console, JSON, XML, and XMP report renderers.
- Read-only publication inspection for metadata, manifest items, images, navigation, and text statistics.
- Image inventory reports with media type, byte size, dimensions, manifest properties, and references.
- Metadata reports for OPF Dublin Core fields, rendition metadata, accessibility-related entries, and package identifiers.
- Custom message override support compatible with the project acceptance tests.
- SpecMason configuration for tracking Gherkin-to-test coverage.
Requirements
- Python 3.10 or newer.
- Runtime dependencies declared in
pyproject.toml:clickdefusedxmljsonpath-nglxmltinycss2
Installation
From PyPI after publication:
python -m pip install pyepubcheck
From a local checkout:
git clone <repository-url>
cd pyepubcheck
python -m pip install -e .
For development, tests, and documentation:
python -m pip install -e ".[dev,docs]"
Quick start
Validate an expanded EPUB directory:
pyepubcheck path/to/book/
Validate packaged EPUB archive structure or a single resource:
pyepubcheck book.epub
pyepubcheck OPS/package.opf
pyepubcheck OPS/chapter-001.xhtml
Inspect a publication:
pyepubcheck inspect book.epub
pyepubcheck images book.epub --sort size --largest 10
pyepubcheck metadata book.epub --format json
pyepubcheck stats book.epub --estimate-pages
Write a JSON report:
pyepubcheck book.epub --json report.json
Fail the command when warnings are present:
pyepubcheck book.epub --failonwarnings
Use a validation profile:
pyepubcheck book.epub --profile accessibility
pyepubcheck book.epub --profile edupub
CLI reference
usage: pyepubcheck [-h] [--version]
{check,inspect,images,metadata,manifest,nav,stats} ...
Legacy validation remains supported:
pyepubcheck book.epub
This behaves like:
pyepubcheck check book.epub
Primary commands:
| Command | Purpose |
|---|---|
check |
Validate a publication and optionally append a compact clean-run summary. |
inspect |
Produce an all-in-one read-only publication overview. |
images |
List image assets, dimensions, byte sizes, properties, and references. |
metadata |
Report stored OPF metadata and package identifiers. |
manifest |
Report manifest items, resolved paths, and file presence. |
nav |
Report TOC, landmarks, and page-list data. |
stats |
Report estimated word and character counts and optional estimated pages. |
Python API
from pyepubcheck.api import validate_path
from pyepubcheck.config import ValidationConfig
from pyepubcheck.severity import Severity
report = validate_path(
"book.epub",
config=ValidationConfig(profile="accessibility", fail_on_warnings=True),
)
for message in report.messages:
print(message.severity.value, message.id, message.message)
exit_code = report.exit_code(fail_on_warnings=True)
assert exit_code in {0, 1}
assert all(message.severity is not Severity.FATAL for message in report.messages)
Documentation
The documentation is authored as Markdown under docs/ and rendered with MyST Parser.
Build it locally:
python -m pip install -e ".[docs]"
sphinx-build -b html docs docs/_build/html
Start with docs/index.md.
Development
python -m pip install -e ".[dev,docs]"
python -m pytest -q
ruff check .
specmason check --json
specmason coverage --json --show gaps
The SpecMason configuration lives in specmason.toml; the imported Gherkin corpus lives under specs/behavior/features.
Release checklist
- Update
pyepubcheck/__init__.pyandpyproject.tomlto the release version. - Run the test suite:
python -m pytest -q. - Run SpecMason checks:
specmason check --json. - Build the docs:
sphinx-build -b html docs docs/_build/html. - Build distributions:
python -m build. - Inspect distributions:
python -m twine check dist/*. - Publish to TestPyPI, install into a clean virtual environment, then publish to PyPI.
License
MIT. See LICENSE.
Attribution
This project is a clean-room Python implementation guided by public EPUB behavior specifications and test scenarios. It is not affiliated with, endorsed by, or maintained by the EPUBCheck project.
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 pyepubcheck-0.1.0.tar.gz.
File metadata
- Download URL: pyepubcheck-0.1.0.tar.gz
- Upload date:
- Size: 74.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf6ef01848bea7af6c0f5f26a53498becc3bf448e6bc42a5899b1c0c9728253b
|
|
| MD5 |
c37552952629b1ef928424d51073f96e
|
|
| BLAKE2b-256 |
29c300527040ef898dd88bd3d7630c7b28f3945eb87c3637aaec536530a5692b
|
File details
Details for the file pyepubcheck-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyepubcheck-0.1.0-py3-none-any.whl
- Upload date:
- Size: 96.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9dcc3fe66047a2fb427605866b11e6e179855e10c4d56da8e7408be79185e54
|
|
| MD5 |
15938fa6428509f523b5673ffdd65a56
|
|
| BLAKE2b-256 |
4066dcf0a7fe45e95b172ac883bf7b634d5c18345d35167689daf837eb4c7e5e
|