diff --git a/LICENSE_TESSERACT.txt b/LICENSE_TESSERACT.txt new file mode 100644 index 0000000..228fd26 --- /dev/null +++ b/LICENSE_TESSERACT.txt @@ -0,0 +1,220 @@ +This license applies to the bundled Tesseract OCR binary distributed +inside DataTools installer artifacts (Windows .exe, macOS .dmg, Linux +.AppImage) and the corresponding portable .zip downloads. + +Tesseract OCR upstream: https://github.com/tesseract-ocr/tesseract +Copyright (C) 2006-2024 Google Inc. and the Tesseract OCR contributors + +The Tesseract OCR binary is distributed under the Apache License, +Version 2.0, the full text of which is reproduced verbatim below. + +The bundled `eng.traineddata` data file is the "best" English model +from https://github.com/tesseract-ocr/tessdata_best and is licensed +under the Apache License, Version 2.0 as well. + +DataTools itself is proprietary and is NOT covered by this license; +see LICENSE.txt at the repository root for DataTools' own license. + +================================================================================ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for describing the origin of the Work and + reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may accept and charge a + fee for, acceptance of support, warranty, indemnity, or other + liability obligations and/or rights consistent with this License. + However, in accepting such obligations, You may act only on Your + own behalf and on Your sole responsibility, not on behalf of any + other Contributor, and only if You agree to indemnify, defend, + and hold each Contributor harmless for any liability incurred by, + or claims asserted against, such Contributor by reason of your + accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. diff --git a/README.es.md b/README.es.md index 15df30c..829a57b 100644 --- a/README.es.md +++ b/README.es.md @@ -30,7 +30,9 @@ Paquetes precompilados — sin instalar Python, sin permisos de administrador, s | **Windows** | `DataTools-X.Y.Z-win-setup.exe` — ejecuta el instalador (por usuario, sin admin). Crea acceso directo en el escritorio + entrada en el menú Inicio. | `DataTools-X.Y.Z-win-portable.zip` — descomprime donde quieras, doble clic en `DataTools.exe`. | | **Linux** | `DataTools-X.Y.Z-linux-x86_64.AppImage` — `chmod +x` y doble clic. | El AppImage ya es portable. | -Última versión: consulta [GitHub Releases](https://git.invixiom.com/giteadmin/datatools-dev/releases) (o el listado de Gumroad). Cada paquete ocupa ~200 MB descomprimido; al primer arranque la app levanta un servidor local en http://127.0.0.1:8501 y abre tu navegador predeterminado. Nada sale de tu equipo — instalador y portable son idénticos por dentro. +Última versión: consulta [GitHub Releases](https://git.invixiom.com/giteadmin/datatools-dev/releases) (o el listado de Gumroad). Cada paquete ocupa ~300 MB descomprimido; al primer arranque la app levanta un servidor local en http://127.0.0.1:8501 y abre tu navegador predeterminado. Nada sale de tu equipo — instalador y portable son idénticos por dentro. + +**Tesseract OCR viene incluido.** El soporte para PDFs escaneados del Extractor de PDF funciona sin configuración adicional en las tres plataformas — no hace falta instalar Tesseract por separado. Atribución de licencia: ver [`LICENSE_TESSERACT.txt`](LICENSE_TESSERACT.txt). **Avisos del primer arranque (una sola vez):** - **macOS** sin firma: clic derecho → **Abrir** → confirma. (Las compilaciones firmadas se lo saltan.) diff --git a/README.md b/README.md index 797dccf..44c95b9 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ Pre-built bundles — no Python install, no admin rights, no internet at runtime | **Windows** | `DataTools-X.Y.Z-win-setup.exe` — run installer (per-user, no admin). Desktop shortcut + Start Menu entry created. | `DataTools-X.Y.Z-win-portable.zip` — unzip anywhere, double-click `DataTools.exe`. | | **Linux** | `DataTools-X.Y.Z-linux-x86_64.AppImage` — `chmod +x`, double-click. | The AppImage is already portable. | -Latest release: see [GitHub Releases](https://git.invixiom.com/giteadmin/datatools-dev/releases) (or the Gumroad listing). Each bundle is ~200 MB unpacked; on first launch the app starts a local server at http://127.0.0.1:8501 and opens your default browser. Nothing leaves your machine — installers and portables are byte-identical inside. +Latest release: see [GitHub Releases](https://git.invixiom.com/giteadmin/datatools-dev/releases) (or the Gumroad listing). Each bundle is ~300 MB unpacked; on first launch the app starts a local server at http://127.0.0.1:8501 and opens your default browser. Nothing leaves your machine — installers and portables are byte-identical inside. + +**Tesseract OCR is bundled.** Scanned-PDF support in the PDF Extractor works out of the box on all three platforms — no separate Tesseract install required. License attribution: see [`LICENSE_TESSERACT.txt`](LICENSE_TESSERACT.txt). **First-launch warnings (one-time):** - **macOS** unsigned builds: right-click → **Open** → confirm. (Signed builds skip this.) diff --git a/build/README.md b/build/README.md index f67df4c..fe31ec6 100644 --- a/build/README.md +++ b/build/README.md @@ -54,8 +54,11 @@ for buyers (or IT-locked-down machines) that can't run installers: | Linux | `DataTools--linux-x86_64.AppImage`| (the AppImage IS the portable) | All six outputs are self-contained: every dependency (Python, pandas, -streamlit, pdfplumber, the lot) is frozen into the bundle. The buyer -does not need to install Python, pip, or anything else first. +streamlit, pdfplumber, **Tesseract OCR + `eng.traineddata`**, the lot) +is frozen into the bundle. The buyer does not need to install Python, +pip, Tesseract, or anything else first. With Tesseract bundled, each +artifact is roughly **250–300 MB** on disk (up from ~120 MB pre-OCR); +unpacked installs run ~300–400 MB once scratch space is counted. ## Easy-launch surface @@ -287,6 +290,56 @@ Mac code-signing in CI requires the cert + private key as a GitHub secret (encoded with `base64`). Detailed walkthrough belongs in a later doc — for v1, sign locally and upload to GitHub Releases. +## Tesseract bundling (PDF Extractor OCR) + +Frozen artifacts ship a per-platform Tesseract binary plus the English +`eng.traineddata` model so scanned-PDF support in the PDF Extractor +works out of the box — no separate user install. Source / pip +developer setups still need system Tesseract on `PATH`. + +**Layout inside the bundle**: + +``` +DataTools/ (or DataTools.app/Contents/MacOS/) +└── tesseract/ + ├── tesseract (Linux/macOS binary; tesseract.exe on Windows) + └── tessdata/ + └── eng.traineddata +``` + +The runtime resolver (in `src/`, owned by the runtime team) walks: + +1. `DATATOOLS_TESSERACT_BIN` env var override. +2. `Path(sys._MEIPASS) / "tesseract" / "tesseract[.exe]"` — frozen + bundles only. +3. `tesseract` on `PATH`. +4. Windows well-known paths. + +**Where the bytes come from**: + +- **Tessdata** — vendored in-repo at `build/vendor/tessdata/eng.traineddata` + (sourced from [tessdata_best](https://github.com/tesseract-ocr/tessdata_best)). + `datatools.spec` copies it into `tesseract/tessdata/`. +- **Binary** — fetched per-platform at build time by + `build/make_release.py` from pinned upstream URLs. Current pin: + **Tesseract 5.5.0**. + +**Updating Tesseract**: + +1. Bump the version pin and the per-platform fetch URLs in + `build/make_release.py`. +2. If the model schema changed upstream, refresh + `build/vendor/tessdata/eng.traineddata` from `tessdata_best` at the + matching tag. +3. Rebuild on each platform (`python build/make_release.py`) and + smoke-test a scanned PDF through the PDF Extractor. +4. Update `LICENSE_TESSERACT.txt` at the repo root if upstream license + terms change (Apache-2.0 today). + +License attribution for the bundled binary lives at +`LICENSE_TESSERACT.txt` at the repo root — it must ship alongside any +binary that contains Tesseract. + ## Common pitfalls | Symptom | Fix | diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index 6952d4e..62a67b1 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -296,6 +296,37 @@ GUI / CLI handlers: use `format_for_user(exc, context="...")` to render. All `DataToolsError` subclasses extend stdlib `ValueError` or `OSError` so existing handlers still catch them. +## PDF Extractor — bundled Tesseract + +Frozen builds (installer / portable .zip / AppImage) ship Tesseract OCR inside the bundle so scanned PDFs work without a separate system install. Source / `pip` developer environments still resolve Tesseract from `PATH`. + +**Runtime layout (frozen bundles)**: + +| Resource | Path | +|---|---| +| Tesseract binary | `Path(sys._MEIPASS) / "tesseract" / "tesseract"` (Linux/macOS), `…/tesseract/tesseract.exe` (Windows) | +| Tessdata directory | `Path(sys._MEIPASS) / "tesseract" / "tessdata"` | +| English model | `Path(sys._MEIPASS) / "tesseract" / "tessdata" / "eng.traineddata"` | + +**Discovery order** (PDF Extractor runtime): + +1. `DATATOOLS_TESSERACT_BIN` env var (override — explicit path to a `tesseract` binary). +2. Bundled path under `sys._MEIPASS` (frozen bundles only — falls through to step 3 otherwise). +3. `tesseract` on `PATH` (developer setups, source checkouts). +4. Windows well-known locations (`C:\Program Files\Tesseract-OCR\tesseract.exe`, etc.). + +**Where the bytes come from**: + +- **Tessdata** is vendored at `build/vendor/tessdata/eng.traineddata` — the "best" English model from [tessdata_best](https://github.com/tesseract-ocr/tessdata_best). PyInstaller's spec copies it into `tesseract/tessdata/` inside the bundle. +- **Tesseract binary** is fetched at build time by `build/make_release.py` — per-platform download URLs are pinned in that script. The current pin is **Tesseract 5.5.0**. + +**To update Tesseract**: + +1. Bump the version pin + the per-platform fetch URLs in `build/make_release.py`. +2. If upstream changed the `eng.traineddata` schema, refresh `build/vendor/tessdata/eng.traineddata` from `tessdata_best` at the matching tag. +3. Rebuild on each platform (`python build/make_release.py`) and smoke-test a scanned-PDF run through the PDF Extractor before tagging the release. +4. Update `LICENSE_TESSERACT.txt` at the repo root if the upstream license terms change (Tesseract is Apache-2.0 today). + ## Tests ```bash diff --git a/docs/TECHNICAL.md b/docs/TECHNICAL.md index e9ea23e..505b7ae 100644 --- a/docs/TECHNICAL.md +++ b/docs/TECHNICAL.md @@ -122,6 +122,17 @@ Tag a release → 3 platform artifacts upload to GitHub Releases. Manual: copy t `demo/streamlit_app.py` → Streamlit Community Cloud. Configure deployment in Streamlit UI. Custom domain via CNAME (verify policy at deploy time). Fall back to $5/mo VPS if rate limits / branding constraints hit. +### 3.10 Bundled Tesseract (PDF Extractor OCR) + +Frozen builds ship Tesseract 5.5 + `eng.traineddata` inside the PyInstaller bundle so scanned PDFs work without a separate install. Per-platform binary URLs pinned in `build/make_release.py`; tessdata vendored at `build/vendor/tessdata/eng.traineddata`. License attribution in `LICENSE_TESSERACT.txt` at the repo root. + +**Discovery order at runtime** (see `docs/DEVELOPER.md` for the full Path layout): + +1. `DATATOOLS_TESSERACT_BIN` env var override. +2. Bundled path under `sys._MEIPASS / "tesseract" /` (frozen bundles only). +3. `tesseract` on `PATH` (source / pip developer environments). +4. Windows well-known locations. + ## 4. Libraries | Purpose | Library | diff --git a/docs/USER-GUIDE.es.md b/docs/USER-GUIDE.es.md index e4f6a5d..6e2e984 100644 --- a/docs/USER-GUIDE.es.md +++ b/docs/USER-GUIDE.es.md @@ -103,7 +103,9 @@ La ventana del lanzador queda abierta en segundo plano. Cerrarla detiene el serv - Windows 10/11 (64 bits), macOS 11+, Linux moderno (2020+). - Navegador moderno (Chrome, Edge, Firefox, Safari, últimos 3 años). -- ~400 MB de espacio libre en disco (el paquete ocupa ~200 MB; el resto es espacio de trabajo para CSV grandes). +- ~500 MB de espacio libre en disco (el paquete ocupa ~300 MB; el resto es espacio de trabajo para CSV grandes). + +**OCR para PDFs escaneados viene incluido** — Tesseract 5.5 y el modelo en inglés `eng.traineddata` vienen dentro de cada instalador / portable / AppImage. La ruta de extracción de PDFs escaneados del Extractor de PDF funciona sin configuración adicional; no hace falta instalar nada por separado. (Quien ejecute desde un checkout con `pip install -r requirements.txt` sigue necesitando Tesseract del sistema en el `PATH` — ver [DEVELOPER.md §PDF Extractor — bundled Tesseract](DEVELOPER.md#pdf-extractor--bundled-tesseract) (solo en inglés).) Matriz de soporte completa: [REQUIREMENTS.md](REQUIREMENTS.md) (solo en inglés). diff --git a/docs/USER-GUIDE.md b/docs/USER-GUIDE.md index e427c07..4d567de 100644 --- a/docs/USER-GUIDE.md +++ b/docs/USER-GUIDE.md @@ -103,7 +103,9 @@ The launcher window stays open in the background. Closing it stops the server - Windows 10/11 (64-bit), macOS 11+, modern Linux (2020+). - Modern browser (Chrome, Edge, Firefox, Safari, last 3 years). -- ~400 MB free disk space (the bundle itself is ~200 MB; the rest is working scratch space for large CSVs). +- ~500 MB free disk space (the bundle itself is ~300 MB; the rest is working scratch space for large CSVs). + +**OCR for scanned PDFs is bundled** — Tesseract 5.5 + the English `eng.traineddata` model ship inside every installer / portable / AppImage. The PDF Extractor's scanned-statement path works out of the box; no separate install required. (Developers running from a `pip install -r requirements.txt` checkout still need system Tesseract on `PATH` — see [DEVELOPER.md §PDF Extractor — bundled Tesseract](DEVELOPER.md#pdf-extractor--bundled-tesseract).) Full numbered support matrix: [REQUIREMENTS.md](REQUIREMENTS.md).