Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
214 lines (201 loc) · 10.6 KB
/
Copy pathpyproject.toml
File metadata and controls
214 lines (201 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
# 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
# `tetrak-ocr`; [project.scripts] is independent of this, and the command is
# what people actually type.
name = "tetrak"
# Derived from the git tag rather than written here. release.yml computes the
# next version with git-cliff and tags it, so a literal in this file is a second
# source of truth that nothing updates -- it sat at 0.2.2 while the project
# released 1.0.0 through 1.0.3, which would have made the first PyPI upload
# wrong and every later one a rejected duplicate.
dynamic = ["version"]
description = "Local-first transcription pipelines for archival material, and the harnesses that measure them"
readme = "README.md"
requires-python = ">=3.11"
# The package is MIT. The documentation, benchmark results and ground-truth
# transcripts are CC BY 4.0 and shipped alongside it -- see LICENSING.md for
# which licence covers what, and why the corpus images carry neither.
license = "MIT"
license-files = ["LICENSE", "LICENSE-CC-BY-4.0.txt", "LICENSING.md"]
authors = [{ name = "Stephen Masters" }, { name = "Yvette Mankerian" }]
keywords = ["ocr", "tesseract", "archives", "digitisation", "benchmark"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Text Processing",
]
# Core stays deliberately light: Tesseract plus image and PDF handling. Every
# other backend pulls hundreds of megabytes to several gigabytes, and most
# users want one or two of them — so they are extras, not requirements.
dependencies = [
# 13.0 fixes the October 2026 advisories, among them heap overflows in
# the TIFF, JPEG and JPEG 2000 decoders that a crafted scan reaches
# through Image.open(). Archives send scans, so the floor is the patch.
"Pillow>=13.0",
"pytesseract>=0.3",
"pdf2image>=1.16",
# Decides, before any decoder opens a scan, that it really is a JPEG, PNG,
# TIFF or PDF within our limits (imaging.open_image and check_pdf). Grew
# out of this package; 0.x minor releases are additive, a breaking one
# becomes 1.0 and stops at the ceiling.
"sillybos>=6.0.3,<7",
"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`. BSD-3, pure Python, no system
# dependencies -- see the dependency licence audit (product compliance).
"reportlab>=4.0",
]
[project.optional-dependencies]
claude = ["anthropic>=0.28"]
easyocr = ["easyocr>=1.7"]
# The project's own Armenian recogniser, as an EasyOCR custom network. It
# depends on easyocr itself, so this extra pulls that in too. 0.8 ships the
# v6 weights and the word list the backend decodes with (brief 013); the
# backend falls back to greedy decoding on older releases. 0.13 ships v8,
# v7 fine-tuned on books set in italics (brief 023).
armenian = ["tetrak-easyocr-armenian>=0.13"]
# 3.7 is the first release whose PaddleX registers the PP-OCRv6 recognisers
# that custom models such as Calfa's paddle-calfa-tiny are exported as; an
# older paddleocr fails at construction with "`PP-OCRv6_tiny_rec` is not
# registered". The floor also holds the resolver: PaddleX 3.7 caps numpy
# below 2.4, so without it a numpy bump quietly resolved paddleocr back to
# 3.4 (uv.lock, 14 November 2026) and every PP-OCRv6 model stopped loading.
paddle = ["paddleocr>=3.7", "paddlepaddle>=3.2"]
# PaddleOCR-VL, the document vision-language model in the same package.
# The class lives in paddleocr, but the pipeline it builds needs paddlex's
# own `ocr` extra -- without it PaddleOCRVL() raises a DependencyError at
# construction, so `paddleocr[doc-parser]` is not the dependency to declare
# here however much it sounds like it. PaddleOCRVL does not exist before
# paddleocr 3.4; the `paddle` extra's 3.7 floor applies here as well.
paddle-vl = ["paddleocr>=3.7", "paddlex[ocr]>=3.7", "paddlepaddle>=3.2"]
# The `marker` extra is withdrawn. Every marker-pdf release, and surya-ocr
# under it, requires Pillow below 11, which cannot share an environment with
# the Pillow>=13.0 floor above. The backend stays registered and says why it
# is unavailable (registry._WITHDRAWN).
#
# To bring Marker back once marker-pdf allows Pillow 13, restore:
#
# marker = ["marker-pdf>=1.0,<2.0"]
#
# add `marker` back to the `ocr` umbrella, and delete its _WITHDRAWN entry.
# The cap below 2.0 still applies: marker-pdf 2.0 routes through an LLM and
# requires a separately installed llama-server binary, which changes what the
# backend measures. The committed benchmark was produced with 1.x.
# Apple's Vision framework, via a thin PyObjC wrapper. macOS only, hence the
# 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'"]
# Quality scoring for auto-local's winner selection: a spell checker for
# dictionary coverage and GPT-2 for perplexity.
#
# torch is listed explicitly because transformers does not depend on it, but
# qa_score's perplexity path imports it directly -- so `[qa]` without torch
# installed an extra that failed on first use with "No module named 'torch'".
qa = ["pyspellchecker>=0.8", "transformers>=4.40", "torch>=2.0"]
# Builds the Sphinx CLI/API reference published to GitHub Pages. Deliberately
# separate from `docs` below (presentation-generation tooling): this extra
# installs quickly because every backend module guards its heavy import
# behind an availability check, so autodoc can import all of tetrak_ocr
# without torch, paddlepaddle or marker-pdf on the runner.
apidocs = ["sphinx>=8.0", "sphinx-argparse>=0.6.1", "furo>=2024.8", "myst-parser>=4.0"]
# The site itself is Hugo and needs no Python -- see package.json. What is left
# here is the tooling that generates artefacts the site consumes: the benchmark
# chart, the corpus renditions, the slide deck. Pillow and pdf2image, which the
# thumbnail generator also needs, are core dependencies already.
docs = [
"python-pptx>=0.6",
# Draws the benchmark comparison chart from benchmark.csv.
"matplotlib>=3.8",
]
# Turning pages upright before OCR (brief 020). Only `--orient armenian`
# needs these: OpenCV finds the letters whose open sides the measure reads.
# Both already arrive with EasyOCR; declared here for anyone orienting pages
# for Tesseract. Apache 2.0 and BSD -- see the dependency licence audit.
orientation = ["numpy>=1.24", "opencv-python-headless>=4.8"]
# The orientation extra is in dev so that its tests run in CI; it is the one
# extra small enough for that.
dev = ["pytest>=8.0", "pytest-cov>=5.0", "ruff>=0.5", "tetrak[orientation]"]
# 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[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
# churn CI, AGENTS.md and the devcontainer for nothing.
ocr = ["tetrak[claude,easyocr,paddle,paddle-vl,vision,qa,orientation]"]
all = ["tetrak[ocr]"]
[project.scripts]
tetrak-ocr = "tetrak_ocr.cli:main"
[project.urls]
Homepage = "https://github.com/scattercode/tetrak"
Documentation = "https://tetrak.dev/"
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
# Writes the resolved version into the package at build time, so an installed
# copy can report it without git present. Generated, therefore gitignored.
version-file = "src/tetrak_ocr/_version.py"
[tool.hatch.build.targets.wheel]
# tetrak_audio and tetrak_publish are placeholders and are shipped so the
# import paths exist and stay reserved. They carry no dependencies of their
# own yet; each gains an extra when it gains code.
packages = ["src/tetrak_ocr", "src/tetrak_audio", "src/tetrak_publish"]
[tool.hatch.build.targets.sdist]
# The sdist carries no .git, so hatch-vcs cannot re-derive the version from it.
# Including the generated _version.py keeps a build-from-sdist working.
include = ["src", "README.md", "LICENSE", "LICENSE-CC-BY-4.0.txt", "LICENSING.md"]
[tool.ruff]
line-length = 100
# The rule set is declared explicitly rather than left to ruff's defaults,
# because those defaults differ between versions: 0.15 reported 26 problems
# here and 0.16 reported 36, on identical code. An undeclared rule set means CI
# and a developer's machine can disagree purely on which ruff they installed.
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # import sorting
"UP", # pyupgrade
"B", # bugbear
]
ignore = [
# Fires on every module carrying a #!/usr/bin/env python3 line. These began
# life as directly-runnable scripts and the shebangs are accurate history;
# marking a dozen files executable to satisfy a lint rule is the wrong fix.
"EXE001",
# Mutable/callable defaults in argparse-style signatures, used deliberately
# here and never mutated.
"B008",
# Line length is enforced by `ruff format`, which is also run in CI. What
# is left after formatting is long string literals -- report table format
# strings and prose -- which the formatter will not split and which are
# more readable whole. Two tools disagreeing about the same line helps
# nobody.
"E501",
]
# `tools/` is not a package -- its scripts are run directly, so Python puts the
# directory on sys.path and `import tetrak_theme` resolves. isort has no way to
# infer that and files it under third-party, which sorts the shared design
# tokens in among pptx and matplotlib. Declaring it keeps the import where a
# reader expects a local one.
[tool.ruff.lint.isort]
known-first-party = ["tetrak_ocr", "tetrak_theme"]
[tool.pytest.ini_options]
testpaths = ["tests"]
markers = [
# Anything reading the evaluation corpus or invoking a real OCR engine.
# `pytest -m "not slow"` is the fast loop CI runs.
"slow: needs the evaluation corpus or a real OCR engine",
]