From 37e7131a0181fe5321f97932d1c888de1634f8ec Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 20 Jan 2026 11:54:55 -0800 Subject: [PATCH] Drop support for Python 3.10, require Python 3.11+ Python 3.11 is now the minimum supported version. This aligns with the codebase's use of StrEnum (introduced in 3.11) and removes compatibility shims that were only needed for older versions. --- .github/workflows/build.yml | 8 ++++---- .readthedocs.yaml | 2 +- docs/installation.md | 6 +++--- pyproject.toml | 6 +++--- snapcraft.yaml | 21 ++++++++------------- src/ocrmypdf/builtin_plugins/concurrency.py | 7 ++----- 6 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30166062..058c5373 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,11 +22,11 @@ jobs: strategy: matrix: os: [ubuntu-22.04, ubuntu-24.04] - python: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python: ["3.11", "3.12", "3.13", "3.14"] include: - os: ubuntu-22.04 tesseract_ppa: "ppa" - python: "3.10" + python: "3.11" env: OS: ${{ matrix.os }} @@ -102,7 +102,7 @@ jobs: strategy: matrix: os: [macos-latest] - python: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python: ["3.11", "3.12", "3.13", "3.14"] env: OS: ${{ matrix.os }} @@ -165,7 +165,7 @@ jobs: strategy: matrix: os: [windows-latest] - python: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python: ["3.11", "3.12", "3.13", "3.14"] env: OS: ${{ matrix.os }} diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 43b85b58..67e8d311 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,7 +15,7 @@ sphinx: build: os: ubuntu-22.04 tools: - python: "3.10" + python: "3.11" python: install: diff --git a/docs/installation.md b/docs/installation.md index f89f4c74..0185d346 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -487,7 +487,7 @@ You can then run OCRmyPDF in the Windows command prompt or Powershell, prefixing First install the the following prerequisite Cygwin packages using `setup-x86_64.exe`: ``` -python310 (or later) +python311 (or later) python3?-devel python3?-pip python3?-lxml @@ -606,7 +606,7 @@ and verapdf can validate speculative PDF/A conversion. The following versions are required: -- Python 3.10 or newer +- Python 3.11 or newer - Tesseract 4.1.1 or newer - One of: Ghostscript 9.54+ **or** pypdfium2 (Python package) - One of: Ghostscript 9.54+ **or** verapdf (for PDF/A output) @@ -668,7 +668,7 @@ unfortunately, the `pip install` command cannot satisfy all of them. ## Installing HEAD revision from sources -If you have `git` and Python 3.10 or newer installed, you can install +If you have `git` and Python 3.11 or newer installed, you can install from source. When the `pip` installer runs, it will alert you if dependencies are missing. diff --git a/pyproject.toml b/pyproject.toml index a1b1fb37..01c676ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ dynamic = ["version"] description = "OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched" readme = "README.md" license = "MPL-2.0" -requires-python = ">=3.10" +requires-python = ">=3.11" dependencies = [ "deprecation>=2.1.0", "fpdf2>=2.8.0", @@ -66,7 +66,7 @@ source = "vcs" version-file = "src/ocrmypdf/_version.py" [tool.distutils.bdist_wheel] -python-tag = "py310" +python-tag = "py311" [tool.coverage.run] branch = true @@ -117,7 +117,7 @@ module = [ ignore_missing_imports = true [tool.ruff] -target-version = "py310" +target-version = "py311" exclude = ["src/ocrmypdf/_version.py"] # Autogenerated [tool.ruff.lint] diff --git a/snapcraft.yaml b/snapcraft.yaml index b238c765..de9e7589 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -5,7 +5,7 @@ name: ocrmypdf title: OCRmyPDF -base: core22 +base: core24 version: git summary: OCRmyPDF adds a searchable text layer to scanned PDF files description: OCRmyPDF packaged for snap @@ -14,12 +14,13 @@ confinement: strict icon: docs/images/logo-square-256.svg license: MPL-2.0 -architectures: [amd64] +platforms: + amd64: environment: - TESSDATA_PREFIX: $SNAP/usr/share/tesseract-ocr/4.00/tessdata - GS_LIB: $SNAP/usr/share/ghostscript/9.55.0/Resource/Init - GS_FONTPATH: $SNAP/usr/share/ghostscript/9.55.0/Resource/Font + TESSDATA_PREFIX: $SNAP/usr/share/tesseract-ocr/5/tessdata + GS_LIB: $SNAP/usr/share/ghostscript/10.02.1/Resource/Init + GS_FONTPATH: $SNAP/usr/share/ghostscript/10.02.1/Resource/Font LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu apps: @@ -84,11 +85,5 @@ parts: - wheel override-build: | - pip3 install --user dephell[full] - $HOME/.local/bin/dephell deps convert \ - --from-path pyproject.toml \ - --from-format pyproject \ - --to-path setup.py \ - --to-format setuppy - snapcraftctl build - ln -sf ../usr/lib/libsnapcraft-preload.so $SNAPCRAFT_PART_INSTALL/lib/libsnapcraft-preload.so + craftctl default + ln -sf ../usr/lib/libsnapcraft-preload.so $CRAFT_PART_INSTALL/lib/libsnapcraft-preload.so diff --git a/src/ocrmypdf/builtin_plugins/concurrency.py b/src/ocrmypdf/builtin_plugins/concurrency.py index 86603a9d..53c2f3a9 100644 --- a/src/ocrmypdf/builtin_plugins/concurrency.py +++ b/src/ocrmypdf/builtin_plugins/concurrency.py @@ -15,7 +15,6 @@ import threading from collections.abc import Callable, Iterable from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed from contextlib import suppress -from typing import Union from rich.console import Console as RichConsole @@ -25,10 +24,8 @@ from ocrmypdf._progressbar import RichProgressBar from ocrmypdf.exceptions import InputFileError from ocrmypdf.helpers import remove_all_log_handlers -FuturesExecutorClass = Union[ # noqa: UP007 - type[ThreadPoolExecutor], type[ProcessPoolExecutor] -] -Queue = Union[multiprocessing.Queue, queue.Queue] # noqa: UP007 +FuturesExecutorClass = type[ThreadPoolExecutor] | type[ProcessPoolExecutor] +Queue = multiprocessing.Queue | queue.Queue UserInit = Callable[[], None] WorkerInit = Callable[[Queue, UserInit, int], None]