Skip to content

馃悰 Prefer Enhancer virtualenv and fix OCR interpreter selection - #12

Open
JFWooten4 wants to merge 6 commits into
mainfrom
fix-ocr-python-command-resolution
Open

JFWooten4 wants to merge 6 commits into
mainfrom
fix-ocr-python-command-resolution

Conversation

@JFWooten4

@JFWooten4 JFWooten4 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Problem

The OCR shell script checked [[ -x "$tagger_python" ]] while tagger_python=python3, which inspects a relative file rather than resolving an executable on PATH. More importantly, the workflow did not explicitly select an Enhancer-owned Python virtual environment and could mix global/Homebrew Python packages with its own tagging, compression, and review scripts.

Changes

  • Add setup-python-env.sh to create enhancer/.venv and install pikepdf and Pillow.
  • Prefer the project .venv/bin/python consistently for OCR tagging, review and sidecars, plus compression workflows. Report an actionable repair message when the venv is incomplete.
  • Retain the previous PATH / OCRmyPDF interpreter fallback when no project venv exists, preserving standalone compatibility.
  • Fix interpreter command resolution and properly preserve arguments from a Python shebang.
  • Add regression tests for venv priority, incomplete venvs and the previous python3 PATH issue. Run shell startup checks in CI.
  • Document Python environment setup and separate system-managed OCRmyPDF/qpdf binaries.

Integration

The viewer's native-host installer is updated separately in PDF-magic/viewer#203 to provision the project venv on explicit setup and prefer it for metadata stamping.

These changes address demonstrable startup and environment-selection problems; the reported SEC PDF failure cannot be reproduced on the user's Mac from CI.

JFWooten4 and others added 2 commits October 18, 2026 17:29
Accept a working python3 command even when it is not a relative executable file, and inspect OCRmyPDF's shebang only after dependency checks. Cover the startup path with a stubbed OCR regression test.

Co-authored-by: Codex Web <noreply@openai.com>
Generate executable shell stubs with actual line breaks so the regression reaches the interpreter-selection path.

Co-authored-by: Codex Web <noreply@openai.com>
JFWooten4 and others added 4 commits October 18, 2026 17:34
Preserve interpreter arguments discovered from OCRmyPDF's shebang when invoking the tagger, reviewer, and sidecar exporter.

Co-authored-by: Codex Web <noreply@openai.com>
Include OCR shell changes in the existing regression workflow and execute its startup test alongside metadata checks.

Co-authored-by: Codex Web <noreply@openai.com>
Add a dedicated setup script for the project .venv, prioritize it for OCR and compression helpers, retain backward-compatible interpreter selection for existing installations, and test venv precedence and diagnostics.

Co-authored-by: Codex Web <noreply@openai.com>
Assert file markers from test interpreter shims because dependency checks intentionally redirect output to /dev/null.

Co-authored-by: Codex Web <noreply@openai.com>
@JFWooten4 JFWooten4 changed the title 馃悰 Resolve OCR Python executables through PATH 馃悰 Prefer Enhancer virtualenv and fix OCR interpreter selection Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant