Skip to content

Commit 7fc814d

Browse files
committed
Support python 3.9 and above only
Update CI workflows, axe support for EOL python versions Bump version to 0.3.14
1 parent bc0b6b0 commit 7fc814d

File tree

9 files changed

+86
-88
lines changed

9 files changed

+86
-88
lines changed

.github/workflows/ci.yaml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,44 @@ on:
66
tags: '*'
77
pull_request:
88

9+
env:
10+
python-latest:
11+
tag: 'py313'
12+
version: '3.13'
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
918
jobs:
10-
tests:
11-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
12-
name: ${{ matrix.name }}
13-
runs-on: ${{ matrix.os }}
19+
tox:
20+
name: ${{ matrix.env }}
21+
runs-on: ubuntu-latest
1422
strategy:
15-
fail-fast: true
1623
matrix:
17-
include:
18-
- {name: '3.12', python: '3.12', os: ubuntu-latest, tox: py312}
19-
- {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311}
20-
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
21-
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
22-
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
24+
env: [py39, py310, py311, py312, py313]
2325
steps:
24-
- uses: actions/checkout@v4
25-
26-
- name: Setup Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python }}
30-
cache: 'pip'
31-
32-
- name: Upgrade bootstrap packages
33-
run: python -m pip install --upgrade pip tox
34-
35-
- name: Install tesseract
36-
run: sudo apt-get -y update && sudo apt-get install -y tesseract-ocr tesseract-ocr-fra
37-
38-
- name: Print tesseract version
39-
run: echo $(tesseract --version)
40-
41-
- name: Run tox
42-
run: tox -e ${{ matrix.tox }}
43-
env:
44-
PY_COLORS: 1
45-
TOX_TESTENV_PASSENV: PY_COLORS
46-
47-
- name: Test pytesseract package installation
48-
run: pip install -U . && pip show pytesseract && python -c 'import pytesseract'
26+
- uses: asottile/workflows/.github/actions/[email protected]
27+
with:
28+
submodules: false
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: |
32+
${{
33+
(matrix.env == 'py39' || startsWith(matrix.env, 'py39-')) && '3.9' ||
34+
(matrix.env == 'py310' || startsWith(matrix.env, 'py310-')) && '3.10' ||
35+
(matrix.env == 'py311' || startsWith(matrix.env, 'py311-')) && '3.11' ||
36+
(matrix.env == 'py312' || startsWith(matrix.env, 'py312-')) && '3.12' ||
37+
(matrix.env == env.python-latest.tag) && env.python.latest.version
38+
}}
39+
- name: Install tesseract
40+
run: sudo apt-get -y update && sudo apt-get install -y tesseract-ocr tesseract-ocr-fra
41+
- name: Print tesseract version
42+
run: echo $(tesseract --version)
43+
- name: Update tools
44+
run: python -mpip install --upgrade setuptools tox virtualenv
45+
- name: Run tox
46+
run: tox -e ${{ matrix.env != env.python-latest.tag && matrix.env || 'pandas' }}
47+
- name: Test pytesseract package installation
48+
if: ${{ matrix.env == env.python-latest.tag }}
49+
run: python -mpip install -U . && python -mpip show pytesseract && python -c 'import pytesseract'

.pre-commit-config.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ repos:
1010
hooks:
1111
- id: trailing-whitespace
1212
- id: end-of-file-fixer
13-
- id: check-docstring-first
1413
- id: check-yaml
1514
- id: debug-statements
15+
- id: double-quote-string-fixer
1616
- id: name-tests-test
1717
- id: requirements-txt-fixer
18-
- id: double-quote-string-fixer
19-
- repo: https://github.com/PyCQA/flake8
20-
rev: 7.1.1
21-
hooks:
22-
- id: flake8
23-
- repo: https://github.com/hhatto/autopep8
24-
rev: v2.3.1
18+
- id: check-docstring-first
19+
- repo: https://github.com/asottile/setup-cfg-fmt
20+
rev: v2.7.0
2521
hooks:
26-
- id: autopep8
22+
- id: setup-cfg-fmt
2723
- repo: https://github.com/asottile/reorder-python-imports
2824
rev: v3.14.0
2925
hooks:
3026
- id: reorder-python-imports
31-
args: [--py37-plus]
27+
args: [--py39-plus, --add-import, 'from __future__ import annotations']
28+
- repo: https://github.com/asottile/add-trailing-comma
29+
rev: v3.1.0
30+
hooks:
31+
- id: add-trailing-comma
3232
- repo: https://github.com/asottile/pyupgrade
3333
rev: v3.19.0
3434
hooks:
3535
- id: pyupgrade
36-
args: [--py37-plus]
37-
- repo: https://github.com/asottile/add-trailing-comma
38-
rev: v3.1.0
36+
args: [--py39-plus]
37+
- repo: https://github.com/hhatto/autopep8
38+
rev: v2.3.1
3939
hooks:
40-
- id: add-trailing-comma
41-
# - repo: https://github.com/asottile/setup-cfg-fmt
42-
# rev: v1.16.0
43-
# hooks:
44-
# - id: setup-cfg-fmt
40+
- id: autopep8
41+
- repo: https://github.com/PyCQA/flake8
42+
rev: 7.1.1
43+
hooks:
44+
- id: flake8
4545
- repo: local
4646
hooks:
4747
- id: rst

pyproject.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

pytesseract/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# flake8: noqa: F401
2+
from __future__ import annotations
3+
24
from .pytesseract import ALTONotSupported
35
from .pytesseract import get_languages
46
from .pytesseract import get_tesseract_version
@@ -16,4 +18,4 @@
1618
from .pytesseract import TSVNotSupported
1719

1820

19-
__version__ = '0.3.13'
21+
__version__ = '0.3.14'

pytesseract/pytesseract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env python
2+
from __future__ import annotations
3+
24
import logging
35
import re
46
import shlex
@@ -20,8 +22,6 @@
2022
from os.path import realpath
2123
from tempfile import NamedTemporaryFile
2224
from time import sleep
23-
from typing import List
24-
from typing import Optional
2525

2626
from packaging.version import InvalidVersion
2727
from packaging.version import parse
@@ -293,8 +293,8 @@ def _read_output(filename: str, return_bytes: bool = False):
293293

294294
def run_and_get_multiple_output(
295295
image,
296-
extensions: List[str],
297-
lang: Optional[str] = None,
296+
extensions: list[str],
297+
lang: str | None = None,
298298
nice: int = 0,
299299
timeout: int = 0,
300300
return_bytes: bool = False,

setup.cfg

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
11
[metadata]
22
name = pytesseract
33
version = attr: pytesseract.__version__
4-
author = Samuel Hoffstaetter
5-
author_email = [email protected]
6-
maintainer = Matthias Lee
7-
maintainer_email = [email protected]
84
description = Python-tesseract is a python wrapper for Google's Tesseract-OCR
95
long_description = file: README.rst
106
long_description_content_type = text/x-rst
11-
license = Apache License 2.0
12-
license_file = LICENSE
13-
keywords = python-tesseract OCR Python
147
url = https://github.com/madmaze/pytesseract
8+
author = Samuel Hoffstaetter
9+
author_email = [email protected]
10+
maintainer = Matthias Lee
11+
maintainer_email = [email protected]
12+
license = Apache-2.0
13+
license_files = LICENSE
1514
classifiers =
1615
License :: OSI Approved :: Apache Software License
1716
Programming Language :: Python :: 3
1817
Programming Language :: Python :: 3 :: Only
19-
Programming Language :: Python :: 3.8
20-
Programming Language :: Python :: 3.9
21-
Programming Language :: Python :: 3.10
22-
Programming Language :: Python :: 3.11
23-
Programming Language :: Python :: 3.12
2418
Programming Language :: Python :: Implementation :: CPython
2519
Programming Language :: Python :: Implementation :: PyPy
20+
keywords = python-tesseract OCR Python
2621
2722
[options]
2823
packages = find:
29-
include_package_data = True
3024
install_requires =
31-
packaging>=21.3
3225
Pillow>=8.0.0
33-
34-
python_requires = >=3.8
35-
36-
[options.entry_points]
37-
console_scripts =
38-
pytesseract = pytesseract.pytesseract:main
26+
packaging>=21.3
27+
python_requires = >=3.9
28+
include_package_data = True
3929
4030
[options.packages.find]
4131
exclude =
4232
tests*
4333
testing*
34+
35+
[options.entry_points]
36+
console_scripts =
37+
pytesseract = pytesseract.pytesseract:main

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from setuptools import setup
24

35

tests/pytesseract_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from functools import partial
24
from glob import iglob
35
from multiprocessing import Pool
@@ -293,7 +295,7 @@ def test_image_to_alto_xml_support(test_file):
293295
TESSERACT_VERSION[:2] >= (3, 5),
294296
reason='requires tesseract < 3.05',
295297
)
296-
def test_image_to_data__pandas_support(test_file_small):
298+
def test_image_to_data_pandas_support(test_file_small):
297299
with pytest.raises(TSVNotSupported):
298300
image_to_data(test_file_small, output_type=Output.DATAFRAME)
299301

@@ -303,7 +305,7 @@ def test_image_to_data__pandas_support(test_file_small):
303305
reason='requires tesseract >= 3.05',
304306
)
305307
@pytest.mark.skipif(pandas_installed is False, reason='requires pandas')
306-
def test_image_to_data__pandas_output(test_file_small):
308+
def test_image_to_data_pandas_output(test_file_small):
307309
"""Test and compare the type and meta information of the result."""
308310
result = image_to_data(test_file_small, output_type=Output.DATAFRAME)
309311
assert isinstance(result, pandas.DataFrame)

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py, py-slow
2+
envlist = py, pandas
33

44
[pytest]
55
addopts = --strict-markers --verbose --cache-clear --color=yes -p no:doctest
@@ -10,13 +10,15 @@ markers =
1010
[testenv]
1111
deps =
1212
-r{toxinidir}/requirements-dev.txt
13+
passenv = *
1314
commands =
1415
python -bb -m pytest {posargs:tests}
1516

16-
[testenv:py-slow]
17+
[testenv:pandas]
1718
deps =
1819
numpy
1920
pandas
2021
-r{toxinidir}/requirements-dev.txt
22+
passenv = *
2123
commands =
2224
python -bb -m pytest {posargs:tests}

0 commit comments

Comments
 (0)