Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 73 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# semantic version from the Conventional Commit history since the last tag,
# git-cliff regenerates CHANGELOG.md for that version, the commit is tagged,
# and a GitHub Release is published whose notes are that changelog section.
# The sdist and wheel are then built from that tag and published to PyPI as
# `tetrak` through a Trusted Publisher.
#
# The release commit is pushed by the `scattercode-release` App, the only
# actor the main ruleset lets bypass it. That token is a real identity, so
Expand Down Expand Up @@ -175,6 +177,75 @@ jobs:

gh release create "$VERSION" --title "$VERSION" --notes-file RELEASE_NOTES.md

# Build the sdist and wheel from the exact tag the release job just pushed.
# A fresh checkout at the tag is what makes hatch-vcs produce a clean X.Y.Z;
# a build from an untagged commit yields X.Y.Z.devN+gabcdef, which PyPI
# rejects.
build:
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
# The workflow grants contents: write for the release job. This job only
# reads the tag, and it runs third-party build tooling with the checkout
# credential persisted, so it gets no more than it needs.
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.release.outputs.version }}
fetch-depth: 0

- uses: actions/setup-python@v7
with:
python-version: '3.11'

- name: Build sdist and wheel
run: |
python -m pip install --upgrade build twine
python -m build

# Fails on a README that will not render on PyPI, or missing metadata.
- name: Check distribution metadata
run: twine check --strict dist/*

# Install the *wheel* into a clean interpreter and import every package
# it reserves. This catches files that work from `pip install -e .` but
# were left out of the wheel, and a __version__ that disagrees with the
# tag -- the 5.14.0 wheel reported 0.2.2 from a forgotten literal.
- name: Smoke-test the wheel
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
python -m venv /tmp/smoke
/tmp/smoke/bin/pip install --quiet dist/*.whl
/tmp/smoke/bin/python -c "import os, tetrak_audio, tetrak_publish, tetrak_ocr as t; v = os.environ['VERSION'].removeprefix('v'); assert t.__version__ == v, (t.__version__, v); print(t.__version__)"
/tmp/smoke/bin/tetrak-ocr --help > /dev/null

- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/

# Upload with a Trusted Publisher. No token is stored anywhere: the job
# proves its identity to PyPI with a short-lived OIDC token, which is why
# id-token: write is the only permission it needs. Attestations (PEP 740)
# are generated and uploaded by the action automatically.
publish:
needs: [release, build]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
environment: pypi # must match the name registered on PyPI
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/

- uses: pypa/gh-action-pypi-publish@release/v1

# Which install targets need an SBOM, read from pyproject.toml rather than
# written down here. Adding an extra publishes its SBOM with no workflow
# edit, which is the point: a hand-maintained list is one release away from
Expand Down Expand Up @@ -255,7 +326,7 @@ jobs:
- name: Generate SBOM
run: |
syft scan dir:.sbomvenv \
--source-name "tetrak-ocr${{ matrix.extras }}" \
--source-name "tetrak${{ matrix.extras }}" \
--source-version "${{ needs.release.outputs.version }}" \
-o cyclonedx-json="sbom-${{ matrix.target }}.cdx.json"

Expand All @@ -272,7 +343,7 @@ jobs:
- name: Record the install target and platform
run: |
python3 tools/annotate_sbom.py "sbom-${{ matrix.target }}.cdx.json" \
--target "tetrak-ocr${{ matrix.extras }}"
--target "tetrak${{ matrix.extras }}"

- name: Check the SBOM actually describes something
run: |
Expand Down
6 changes: 6 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ Releases are automated — do not perform them by hand.
with `GITHUB_TOKEN` never triggers the required checks, so it could never
merge either. Issuing CI an admin token was the alternative and was
declined. Tags are unaffected: a tag is not a branch.
- After tagging, `release.yml` builds the sdist and wheel from the tag and
publishes them to PyPI as **`tetrak`** through a Trusted Publisher (the
`pypi` GitHub environment; no token is stored). The distribution is
`tetrak`, the import package `tetrak_ocr` and the command `tetrak-ocr` —
install instructions and error messages say `pip install tetrak`, never
`tetrak-ocr`, which is a name we do not own.
- Never edit `CHANGELOG.md` by hand — change the commit messages or the
`commit_parsers` in `cliff.toml` instead.
- Never create tags or Releases manually.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
**Custodian of the forgotten.** A local-first OCR orchestrator for archival
material — postcards, posters, playbills, programmes and trade papers.

> Published as the `tetrak-ocr` package: every command below is unchanged.
> Tetrak OCR is the product name; the distribution has not followed it yet.
> Install it as `pip install tetrak`. The command it provides is still
> `tetrak-ocr`, so every command below is unchanged.

**📖 [Full documentation](https://tetrak.dev/)**

Expand All @@ -17,9 +17,9 @@ explicitly ask for the Claude backend.
## Install

```bash
pip install tetrak-ocr # core: Tesseract, images and PDFs
pip install 'tetrak-ocr[qa]' # enables auto-local — the recommended default
pip install 'tetrak-ocr[all]' # everything, several gigabytes
pip install tetrak # core: Tesseract, images and PDFs
pip install 'tetrak[qa]' # enables auto-local — the recommended default
pip install 'tetrak[all]' # everything, several gigabytes
Comment on lines +20 to +22

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 69fd34e.

```

`[qa]` is what turns `auto-local` on, because scoring needs a spell checker and
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"python-dotenv>=1.0",
# Writes the searchable PDF. Core rather than an extra because the roadmap
# treats that as the flagship catalogue-ready output, and it should work on
# a plain `pip install tetrak-ocr`. BSD-3, pure Python, no system
# a plain `pip install tetrak`. BSD-3, pure Python, no system
# dependencies -- see the dependency licence audit (product compliance).
"reportlab>=4.0",
]
Expand All @@ -73,7 +73,7 @@ paddle-vl = ["paddleocr>=3.4", "paddlex[ocr]>=3.4", "paddlepaddle>=3.2"]
# the backend measures. The committed benchmark was produced with 1.x.
marker = ["marker-pdf>=1.0,<2.0"]
# Apple's Vision framework, via a thin PyObjC wrapper. macOS only, hence the
# marker: without it `pip install "tetrak-ocr[all]"` would fail on Linux.
# marker: without it `pip install "tetrak[all]"` would fail on Linux.
# Vision itself ships with the OS, so this extra downloads a wrapper and
# nothing else -- no weights, no torch.
vision = ["ocrmac>=1.0; sys_platform == 'darwin'"]
Expand Down Expand Up @@ -102,7 +102,7 @@ docs = [
dev = ["pytest>=8.0", "pytest-cov>=5.0", "ruff>=0.5"]
# Composed from the other extras rather than restating them. The hand-written
# copy had drifted: it listed pyspellchecker and transformers but not torch, so
# `pip install "tetrak-ocr[all]"` -- the command the docs lead with -- left
# `pip install "tetrak[all]"` -- the command the docs lead with -- left
# auto-local unavailable, which is the one backend the docs recommend.
# Per-pipeline umbrellas. The individual extras keep their own names --
# `easyocr` and a future `whisper` do not collide, so namespacing them would
Expand Down
2 changes: 1 addition & 1 deletion site/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ machine.
## Get it

```bash
pip install "tetrak-ocr[all]"
pip install "tetrak[all]"
tetrak-ocr batch --backend auto-local
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Three ways to use it, all Apache 2.0:
- `pip install tetrak-easyocr-armenian` — two lines of Python and an
[EasyOCR](https://github.com/JaidedAI/EasyOCR) reader that speaks
Armenian, weights fetched and checksum-verified on first use.
- `pip install "tetrak-ocr[armenian]"` — the `easyocr-hy` backend, which
- `pip install "tetrak[armenian]"` — the `easyocr-hy` backend, which
adds the two output-path steps described below and is what produced the
numbers here. See [the engines page]({{< relref "/reference/engines.md" >}}).
- [`tetrak/easyocr-armenian`](https://huggingface.co/tetrak/easyocr-armenian)
Expand Down
24 changes: 12 additions & 12 deletions site/content/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Four steps from nothing to a transcribed batch.
{{< tab "macOS" >}}
```bash
brew install tesseract poppler
pip install "tetrak-ocr[all]"
pip install "tetrak[all]"
```
{{< /tab >}}
{{< tab "Debian / Ubuntu" >}}
```bash
sudo apt-get install tesseract-ocr poppler-utils
pip install "tetrak-ocr[all]"
pip install "tetrak[all]"
```
{{< /tab >}}
{{< /tabs >}}

`[all]` installs every optional backend. If you would rather start small, plain
`pip install tetrak-ocr` gives you Tesseract, image handling and PDF
`pip install tetrak` gives you Tesseract, image handling and PDF
rasterisation — see [the extras](#optional-backends) below for what each
addition buys.

Expand Down Expand Up @@ -62,7 +62,7 @@ checkout rather than just the package — the corpus ships with the repository.
## The package

```bash
pip install tetrak-ocr
pip install tetrak
```

That gives you Tesseract, image handling and PDF rasterisation — enough to
Expand All @@ -73,13 +73,13 @@ process a folder of scans offline. Everything else is an optional extra.
Each heavy backend is an extra, so you install only what you intend to use:

```bash
pip install 'tetrak-ocr[claude]' # Anthropic vision API
pip install 'tetrak-ocr[easyocr]' # EasyOCR (CRAFT + CRNN)
pip install 'tetrak-ocr[paddle]' # PaddleOCR
pip install 'tetrak-ocr[paddle-vl]' # PaddleOCR-VL (document vision-language model)
pip install 'tetrak-ocr[marker]' # Marker, layout-aware PDF/image conversion
pip install 'tetrak-ocr[qa]' # quality scoring used by auto-local
pip install 'tetrak-ocr[all]' # all of the above
pip install 'tetrak[claude]' # Anthropic vision API
pip install 'tetrak[easyocr]' # EasyOCR (CRAFT + CRNN)
pip install 'tetrak[paddle]' # PaddleOCR
pip install 'tetrak[paddle-vl]' # PaddleOCR-VL (document vision-language model)
pip install 'tetrak[marker]' # Marker, layout-aware PDF/image conversion
pip install 'tetrak[qa]' # quality scoring used by auto-local
pip install 'tetrak[all]' # all of the above
```

They are separated because the difference is not marginal: the core install is
Expand All @@ -94,7 +94,7 @@ command rather than raising `ModuleNotFoundError`:
$ tetrak-ocr ocr scan.jpg --backend paddle
error: The 'paddle' backend needs the 'paddleocr' and 'paddlepaddle' packages,
not installed here.
Install with: pip install 'tetrak-ocr[paddle]'
Install with: pip install 'tetrak[paddle]'
```

{{< note kind="warning" title="The `marker` extra is copyleft" >}}
Expand Down
6 changes: 3 additions & 3 deletions site/content/reference/engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ retraining:
encyclopedia, whose three columns are set closer together than EasyOCR
pads its boxes, this step is most of the character similarity.

Needs `pip install "tetrak-ocr[armenian]"`. The recogniser's weights (~15 MB)
Needs `pip install "tetrak[armenian]"`. The recogniser's weights (~15 MB)
download on first use, pinned to one immutable revision per release and
checksum-verified; EasyOCR's detector weights come with them. No PDFs —
convert pages to images first.
Expand Down Expand Up @@ -206,7 +206,7 @@ names the `native` path explicitly and passes neither, so a local backend
cannot start sending archive images to a third party because a default
changed. A test asserts it.

Needs `pip install "tetrak-ocr[paddle-vl]"`, which pulls `paddlex[ocr]` —
Needs `pip install "tetrak[paddle-vl]"`, which pulls `paddlex[ocr]` —
not `paddleocr[doc-parser]`, however much that sounds like the one. Model
weights (~1 GB) download on first use and cache under `~/.paddlex/`.

Expand All @@ -223,7 +223,7 @@ both route to it.

## Apple Vision

macOS only. `pip install 'tetrak-ocr[vision]'` — the extra pulls a PyObjC
macOS only. `pip install 'tetrak[vision]'` — the extra pulls a PyObjC
wrapper and nothing else, because Vision ships with the operating system.
No weights, no download on first run, no network. Apple states that all of
Vision's processing happens on the device, so it sits inside the local-first
Expand Down
8 changes: 7 additions & 1 deletion src/tetrak_ocr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

from .errors import MissingBackendError, OcrPipelineError, UnknownBackendError

__version__ = "0.2.2"
try:
# Written by hatch-vcs at build time from the git tag, and gitignored. A
# literal here went stale -- it read 0.2.2 in the 5.14.0 wheel -- because
# nothing updates it. Absent only when running from an unbuilt checkout.
from ._version import __version__
except ImportError:
__version__ = "0+unknown"

__all__ = [
"MissingBackendError",
Expand Down
2 changes: 1 addition & 1 deletion src/tetrak_ocr/backends/armenian.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
it was tried.

Requires:
pip install "tetrak-ocr[armenian]"
pip install "tetrak[armenian]"

The recogniser's weights (~15 MB) download on first use from the Hugging
Face model repository, pinned to one immutable revision per release and
Expand Down
4 changes: 2 additions & 2 deletions src/tetrak_ocr/backends/paddle_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
two becomes a measurement instead of a claim.

Requires:
pip install "tetrak-ocr[paddle-vl]"
pip install "tetrak[paddle-vl]"

Usage (standalone):
tetrak-ocr ocr workspace/scans/my-postcard.jpg --backend paddle-vl
Expand Down Expand Up @@ -156,7 +156,7 @@ def ocr_image(path: Path) -> str:

if not _IMPORT_OK:
raise RuntimeError(
'paddle-vl is unavailable: install it with pip install "tetrak-ocr[paddle-vl]"'
'paddle-vl is unavailable: install it with pip install "tetrak[paddle-vl]"'
)

if not path.exists():
Expand Down
2 changes: 1 addition & 1 deletion src/tetrak_ocr/backends/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
evidence about a manuscript one.

Requires macOS and:
pip install 'tetrak-ocr[vision]'
pip install 'tetrak[vision]'

Usage:
tetrak-ocr ocr workspace/scans/my-postcard.jpg --backend vision
Expand Down
2 changes: 1 addition & 1 deletion src/tetrak_ocr/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, backend: str, extra: str, packages: str) -> None:
# relative clause that would have to agree in number with it.
super().__init__(
f"The '{backend}' backend needs {packages}, not installed here.\n"
f"Install with: pip install 'tetrak-ocr[{extra}]'"
f"Install with: pip install 'tetrak[{extra}]'"
)


Expand Down
2 changes: 1 addition & 1 deletion src/tetrak_ocr/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def pdf_renderer():
raise ImportError(
"pdf2image is needed to read PDFs and could not be imported. It is a "
"core dependency, so this install is incomplete: reinstall with "
"`pip install -e .` from a checkout, or `pip install tetrak-ocr`.\n"
"`pip install -e .` from a checkout, or `pip install tetrak`.\n"
"Rendering also needs poppler on the system -- `brew install poppler` "
"on macOS, `apt install poppler-utils` on Debian."
) from None
Expand Down
2 changes: 1 addition & 1 deletion tests/ocr/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def boom(*a, **k):
img.touch()

assert cli.main(["ocr", str(img), "--backend", "paddle"]) == 1
assert "tetrak-ocr[paddle]" in capsys.readouterr().err
assert "tetrak[paddle]" in capsys.readouterr().err


class TestQualityGateFlag:
Expand Down
4 changes: 2 additions & 2 deletions tests/ocr/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_the_documented_backends_are_all_registered(self) -> None:

def test_core_backends_need_no_extras(self) -> None:
"""Tesseract ships in the core install, so a bare
`pip install tetrak-ocr` must leave the tool usable."""
`pip install tetrak` must leave the tool usable."""
assert is_available("tesseract")
assert is_available("tesseract-auto")

Expand Down Expand Up @@ -134,7 +134,7 @@ def test_the_error_names_the_extra_to_install(self, monkeypatch: pytest.MonkeyPa
get_backend("paddle")

message = str(exc.value)
assert "tetrak-ocr[paddle]" in message, "must give the exact install command"
assert "tetrak[paddle]" in message, "must give the exact install command"
assert "pip install" in message

def test_is_available_reports_false_without_raising(
Expand Down
Loading
Loading