From 3670e9b3c7b8f12ac8db38e1ea15efd4e6317f14 Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Sun, 4 Oct 2026 09:55:57 +0100 Subject: [PATCH 1/3] ci(release): publish each release to PyPI as tetrak Build the sdist and wheel from the release tag, check the metadata, smoke-test the wheel (including that __version__ matches the tag) and upload through a Trusted Publisher in the pypi environment, as the Armenian satellite packages already do. The SBOMs now name the distribution tetrak rather than tetrak-ocr. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/release.yml | 70 ++++++++++++++++++++++++++++++++++- CLAUDE.md | 6 +++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 675e57d..b112f55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -175,6 +177,70 @@ 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 + 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 @@ -255,7 +321,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" @@ -272,7 +338,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: | diff --git a/CLAUDE.md b/CLAUDE.md index 34fd719..ee83f05 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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. From dc66dfc852e73aa2b3874a7fd1bc40c64a708e36 Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Sun, 4 Oct 2026 09:56:44 +0100 Subject: [PATCH 2/3] fix: report the real version and the real distribution name __version__ was a literal 0.2.2 that nothing updated, so the 5.14.0 wheel misreported itself; it now comes from the hatch-vcs _version.py. Every install instruction and missing-extra error said `pip install tetrak-ocr`, but the distribution is tetrak. That name is not ours on PyPI, so following the error message would have installed nothing, or someone else's package. The command stays tetrak-ocr. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 6 ++-- pyproject.toml | 8 +++--- site/content/_index.md | 2 +- ...-09-01-shipping-the-armenian-recogniser.md | 2 +- site/content/install.md | 24 ++++++++-------- site/content/reference/engines.md | 6 ++-- src/tetrak_ocr/__init__.py | 8 +++++- src/tetrak_ocr/backends/armenian.py | 2 +- src/tetrak_ocr/backends/paddle_vl.py | 4 +-- src/tetrak_ocr/backends/vision.py | 2 +- src/tetrak_ocr/errors.py | 2 +- src/tetrak_ocr/imaging.py | 2 +- tests/ocr/test_cli.py | 2 +- tests/ocr/test_registry.py | 4 +-- tests/test_annotate_sbom.py | 28 +++++++++---------- tests/test_install_targets.py | 2 +- tools/annotate_sbom.py | 4 +-- tools/install_targets.py | 6 ++-- 18 files changed, 60 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 48798ac..0dceae7 100644 --- a/README.md +++ b/README.md @@ -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 ``` `[qa]` is what turns `auto-local` on, because scoring needs a spell checker and diff --git a/pyproject.toml b/pyproject.toml index ca0d882..3fd8d1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] -# Not "tetrak-ocr": the distribution carries the audio pipeline and the +# Not "tetrak": the distribution carries the audio pipeline and the # publisher as well, and nobody reading `pip install tetrak-ocr` expects audio # transcription inside it. Renamed while nothing is published -- afterwards it # would mean a deprecated shim and a migration note. The console script stays @@ -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", ] @@ -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'"] @@ -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 diff --git a/site/content/_index.md b/site/content/_index.md index 88718c4..0fe62d5 100644 --- a/site/content/_index.md +++ b/site/content/_index.md @@ -96,7 +96,7 @@ machine. ## Get it ```bash -pip install "tetrak-ocr[all]" +pip install "tetrak[all]" tetrak-ocr batch --backend auto-local ``` diff --git a/site/content/articles/2026/09/2026-09-01-shipping-the-armenian-recogniser.md b/site/content/articles/2026/09/2026-09-01-shipping-the-armenian-recogniser.md index b541840..1ef2c73 100644 --- a/site/content/articles/2026/09/2026-09-01-shipping-the-armenian-recogniser.md +++ b/site/content/articles/2026/09/2026-09-01-shipping-the-armenian-recogniser.md @@ -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) diff --git a/site/content/install.md b/site/content/install.md index 5aad73b..c9f72c0 100644 --- a/site/content/install.md +++ b/site/content/install.md @@ -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. @@ -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 @@ -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 @@ -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" >}} diff --git a/site/content/reference/engines.md b/site/content/reference/engines.md index aba92df..6e58b2c 100644 --- a/site/content/reference/engines.md +++ b/site/content/reference/engines.md @@ -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. @@ -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/`. @@ -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 diff --git a/src/tetrak_ocr/__init__.py b/src/tetrak_ocr/__init__.py index e08b179..68df6d0 100644 --- a/src/tetrak_ocr/__init__.py +++ b/src/tetrak_ocr/__init__.py @@ -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", diff --git a/src/tetrak_ocr/backends/armenian.py b/src/tetrak_ocr/backends/armenian.py index 0f02145..7f9799b 100644 --- a/src/tetrak_ocr/backends/armenian.py +++ b/src/tetrak_ocr/backends/armenian.py @@ -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 diff --git a/src/tetrak_ocr/backends/paddle_vl.py b/src/tetrak_ocr/backends/paddle_vl.py index b672d5f..d7705ae 100644 --- a/src/tetrak_ocr/backends/paddle_vl.py +++ b/src/tetrak_ocr/backends/paddle_vl.py @@ -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 @@ -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(): diff --git a/src/tetrak_ocr/backends/vision.py b/src/tetrak_ocr/backends/vision.py index 08afbf3..27ce1d1 100644 --- a/src/tetrak_ocr/backends/vision.py +++ b/src/tetrak_ocr/backends/vision.py @@ -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 diff --git a/src/tetrak_ocr/errors.py b/src/tetrak_ocr/errors.py index d2d0fa4..73d6ac5 100644 --- a/src/tetrak_ocr/errors.py +++ b/src/tetrak_ocr/errors.py @@ -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}]'" ) diff --git a/src/tetrak_ocr/imaging.py b/src/tetrak_ocr/imaging.py index 75a93a6..e5f1325 100644 --- a/src/tetrak_ocr/imaging.py +++ b/src/tetrak_ocr/imaging.py @@ -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 diff --git a/tests/ocr/test_cli.py b/tests/ocr/test_cli.py index c5e71a2..bdf4e5f 100644 --- a/tests/ocr/test_cli.py +++ b/tests/ocr/test_cli.py @@ -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: diff --git a/tests/ocr/test_registry.py b/tests/ocr/test_registry.py index dacc2d8..6c38510 100644 --- a/tests/ocr/test_registry.py +++ b/tests/ocr/test_registry.py @@ -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") @@ -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( diff --git a/tests/test_annotate_sbom.py b/tests/test_annotate_sbom.py index 5e8ed2f..6224e31 100644 --- a/tests/test_annotate_sbom.py +++ b/tests/test_annotate_sbom.py @@ -39,18 +39,18 @@ def ours(document: dict) -> dict[str, str]: class TestWhatIsRecorded: def test_the_install_target_is_recorded(self) -> None: """Without it, every document names its subject the same thing.""" - d = annotate(bom(), "tetrak-ocr[vision]") - assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak-ocr[vision]" + d = annotate(bom(), "tetrak[vision]") + assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak[vision]" def test_the_platform_is_recorded(self) -> None: """The reason vision's SBOM is smaller than core's, not a defect.""" - recorded = ours(annotate(bom(), "tetrak-ocr")) + recorded = ours(annotate(bom(), "tetrak")) assert recorded[f"{NAMESPACE}:platform:os"] assert recorded[f"{NAMESPACE}:platform:arch"] def test_the_python_version_is_recorded(self) -> None: """A different minor version resolves different wheels.""" - d = annotate(bom(), "tetrak-ocr", python_version="3.12.1") + d = annotate(bom(), "tetrak", python_version="3.12.1") assert ours(d)[f"{NAMESPACE}:python:version"] == "3.12.1" def test_every_property_is_namespaced(self) -> None: @@ -61,7 +61,7 @@ def test_every_property_is_namespaced(self) -> None: class TestItDoesNotDamageTheDocument: def test_components_are_untouched(self) -> None: - d = annotate(bom(), "tetrak-ocr") + d = annotate(bom(), "tetrak") assert d["components"] == [{"type": "library", "name": "pillow", "version": "12.3.0"}] def test_foreign_properties_survive(self) -> None: @@ -73,17 +73,17 @@ def test_foreign_properties_survive(self) -> None: def test_running_twice_does_not_duplicate(self) -> None: """Re-annotating replaces our keys rather than appending them again.""" - d = annotate(annotate(bom(), "tetrak-ocr[qa]"), "tetrak-ocr[qa]") + d = annotate(annotate(bom(), "tetrak[qa]"), "tetrak[qa]") - assert len(ours(d)) == len(properties("tetrak-ocr[qa]")) + assert len(ours(d)) == len(properties("tetrak[qa]")) def test_re_annotating_updates_the_value(self) -> None: - d = annotate(annotate(bom(), "tetrak-ocr[qa]"), "tetrak-ocr[all]") - assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak-ocr[all]" + d = annotate(annotate(bom(), "tetrak[qa]"), "tetrak[all]") + assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak[all]" def test_a_document_without_metadata_is_handled(self) -> None: - d = annotate({"bomFormat": "CycloneDX", "components": []}, "tetrak-ocr") - assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak-ocr" + d = annotate({"bomFormat": "CycloneDX", "components": []}, "tetrak") + assert ours(d)[f"{NAMESPACE}:install-target"] == "tetrak" class TestTheDocumentStaysValidJson: @@ -94,16 +94,16 @@ def test_it_round_trips_through_the_cli(self, tmp_path: Path) -> None: p.write_text(json.dumps(bom()), encoding="utf-8") subprocess.run( - [sys.executable, str(TOOL), str(p), "--target", "tetrak-ocr[marker]"], + [sys.executable, str(TOOL), str(p), "--target", "tetrak[marker]"], check=True, capture_output=True, ) reloaded = json.loads(p.read_text(encoding="utf-8")) assert reloaded["specVersion"] == "1.7" - assert ours(reloaded)[f"{NAMESPACE}:install-target"] == "tetrak-ocr[marker]" + assert ours(reloaded)[f"{NAMESPACE}:install-target"] == "tetrak[marker]" -@pytest.mark.parametrize("target", ["tetrak-ocr", "tetrak-ocr[all]", "tetrak-ocr[vision]"]) +@pytest.mark.parametrize("target", ["tetrak", "tetrak[all]", "tetrak[vision]"]) def test_each_published_target_annotates(target: str) -> None: assert ours(annotate(bom(), target))[f"{NAMESPACE}:install-target"] == target diff --git a/tests/test_install_targets.py b/tests/test_install_targets.py index 6c899e2..870999a 100644 --- a/tests/test_install_targets.py +++ b/tests/test_install_targets.py @@ -37,7 +37,7 @@ def write_pyproject(tmp_path: Path, extras: dict[str, list[str]]) -> Path: class TestDerivation: def test_core_is_always_a_target(self, tmp_path: Path) -> None: - """`pip install tetrak-ocr` with no extras is what most people do.""" + """`pip install tetrak` with no extras is what most people do.""" found = targets(write_pyproject(tmp_path, {})) assert [t["target"] for t in found] == ["core"] assert found[0]["spec"] == "." diff --git a/tools/annotate_sbom.py b/tools/annotate_sbom.py index 8607ac4..ee5c535 100644 --- a/tools/annotate_sbom.py +++ b/tools/annotate_sbom.py @@ -22,7 +22,7 @@ flags cannot. Run: - python3 tools/annotate_sbom.py sbom-vision.cdx.json --target 'tetrak-ocr[vision]' + python3 tools/annotate_sbom.py sbom-vision.cdx.json --target 'tetrak[vision]' """ from __future__ import annotations @@ -70,7 +70,7 @@ def annotate(document: dict, target: str, python_version: str | None = None) -> def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("sbom", type=Path, help="the CycloneDX JSON document to annotate") - parser.add_argument("--target", required=True, help="e.g. tetrak-ocr[vision]") + parser.add_argument("--target", required=True, help="e.g. tetrak[vision]") parser.add_argument("--python-version", help="defaults to the running interpreter") args = parser.parse_args(argv) diff --git a/tools/install_targets.py b/tools/install_targets.py index 40605ff..8c36a2a 100644 --- a/tools/install_targets.py +++ b/tools/install_targets.py @@ -2,7 +2,7 @@ """Enumerate the install targets an SBOM should be published for. A consumer installs one of several different things -- `tetrak-ocr`, -`tetrak-ocr[easyocr]`, `tetrak-ocr[all]` -- and each pulls a different +`tetrak[easyocr]`, `tetrak[all]` -- and each pulls a different dependency closure. An SBOM for one of them says nothing useful about the others: core declares five dependencies, `[all]` resolves to nearly two hundred. @@ -63,7 +63,7 @@ def targets(pyproject: Path) -> list[dict]: "extras": "", "spec": ".", "runner": "ubuntu-latest", - "note": "what `pip install tetrak-ocr` pulls", + "note": "what `pip install tetrak` pulls", } ] @@ -80,7 +80,7 @@ def targets(pyproject: Path) -> list[dict]: # macOS-only extras must be resolved on macOS or the SBOM is a # mislabelled copy of core. "runner": "macos-latest" if darwin_only else "ubuntu-latest", - "note": f"`pip install 'tetrak-ocr[{name}]'`", + "note": f"`pip install 'tetrak[{name}]'`", } ) From 69fd34e2d326aadfe7b2ac17f5a31972627d378d Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Sun, 4 Oct 2026 10:03:39 +0100 Subject: [PATCH 3/3] fix: correct the remaining distribution-name references Address review: the README banner still said the package was tetrak-ocr, the pyproject rename comment had been rewritten to name the wrong package, and install_targets.py mixed both names. The build job now runs with contents: read rather than inheriting write. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/release.yml | 5 +++++ README.md | 4 ++-- pyproject.toml | 2 +- tools/install_targets.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b112f55..29f3927 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -185,6 +185,11 @@ jobs: 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: diff --git a/README.md b/README.md index 0dceae7..8f9c145 100644 --- a/README.md +++ b/README.md @@ -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/)** diff --git a/pyproject.toml b/pyproject.toml index 3fd8d1e..a353703 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] -# Not "tetrak": the distribution carries the audio pipeline and the +# Not "tetrak-ocr": the distribution carries the audio pipeline and the # publisher as well, and nobody reading `pip install tetrak-ocr` expects audio # transcription inside it. Renamed while nothing is published -- afterwards it # would mean a deprecated shim and a migration note. The console script stays diff --git a/tools/install_targets.py b/tools/install_targets.py index 8c36a2a..14cdc63 100644 --- a/tools/install_targets.py +++ b/tools/install_targets.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Enumerate the install targets an SBOM should be published for. -A consumer installs one of several different things -- `tetrak-ocr`, +A consumer installs one of several different things -- `tetrak`, `tetrak[easyocr]`, `tetrak[all]` -- and each pulls a different dependency closure. An SBOM for one of them says nothing useful about the others: core declares five dependencies, `[all]` resolves to nearly two