Skip to content

Commit

Permalink
Support python 3.9 and above only
Browse files Browse the repository at this point in the history
Update CI workflows, axe support for EOL python versions

Bump version to 0.3.14
  • Loading branch information
bozhodimitrov committed Nov 22, 2024
1 parent bc0b6b0 commit 6e4f31c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 88 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ on:
tags: '*'
pull_request:

env:
PYTHON_LATEST_TAG: py313
PYTHON_LATEST_VER: 3.13

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
tests:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
tox:
name: ${{ matrix.env }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- {name: '3.12', python: '3.12', os: ubuntu-latest, tox: py312}
- {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311}
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
env: [py39, py310, py311, py312, py313]
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'

- name: Upgrade bootstrap packages
run: python -m pip install --upgrade pip tox

- name: Install tesseract
run: sudo apt-get -y update && sudo apt-get install -y tesseract-ocr tesseract-ocr-fra

- name: Print tesseract version
run: echo $(tesseract --version)

- name: Run tox
run: tox -e ${{ matrix.tox }}
env:
PY_COLORS: 1
TOX_TESTENV_PASSENV: PY_COLORS

- name: Test pytesseract package installation
run: pip install -U . && pip show pytesseract && python -c 'import pytesseract'
- uses: asottile/workflows/.github/actions/fast-checkout@v1.8.0
with:
submodules: false
- uses: actions/setup-python@v5
with:
python-version: |
${{
(matrix.env == 'py39' || startsWith(matrix.env, 'py39-')) && '3.9' ||
(matrix.env == 'py310' || startsWith(matrix.env, 'py310-')) && '3.10' ||
(matrix.env == 'py311' || startsWith(matrix.env, 'py311-')) && '3.11' ||
(matrix.env == 'py312' || startsWith(matrix.env, 'py312-')) && '3.12' ||
(matrix.env == env.PYTHON_LATEST_TAG) && env.PYTHON_LATEST_VER
}}
- name: Install tesseract
run: sudo apt-get -y update && sudo apt-get install -y tesseract-ocr tesseract-ocr-fra
- name: Print tesseract version
run: echo $(tesseract --version)
- name: Update tools
run: python -mpip install --upgrade setuptools tox virtualenv
- name: Run tox
run: tox -e ${{ matrix.env != env.PYTHON_LATEST_TAG && matrix.env || 'pandas' }}
- name: Test pytesseract package installation
if: ${{ matrix.env == env.PYTHON_LATEST_TAG }}
run: python -mpip install -U . && python -mpip show pytesseract && python -c 'import pytesseract'
36 changes: 18 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: debug-statements
- id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- id: double-quote-string-fixer
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
- id: check-docstring-first
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.7.0
hooks:
- id: autopep8
- id: setup-cfg-fmt
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.14.0
hooks:
- id: reorder-python-imports
args: [--py37-plus]
args: [--py39-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
args: [--py39-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: add-trailing-comma
# - repo: https://github.com/asottile/setup-cfg-fmt
# rev: v1.16.0
# hooks:
# - id: setup-cfg-fmt
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: local
hooks:
- id: rst
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml

This file was deleted.

4 changes: 3 additions & 1 deletion pytesseract/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# flake8: noqa: F401
from __future__ import annotations

from .pytesseract import ALTONotSupported
from .pytesseract import get_languages
from .pytesseract import get_tesseract_version
Expand All @@ -16,4 +18,4 @@
from .pytesseract import TSVNotSupported


__version__ = '0.3.13'
__version__ = '0.3.14'
8 changes: 4 additions & 4 deletions pytesseract/pytesseract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import annotations

import logging
import re
import shlex
Expand All @@ -20,8 +22,6 @@
from os.path import realpath
from tempfile import NamedTemporaryFile
from time import sleep
from typing import List
from typing import Optional

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

def run_and_get_multiple_output(
image,
extensions: List[str],
lang: Optional[str] = None,
extensions: list[str],
lang: str | None = None,
nice: int = 0,
timeout: int = 0,
return_bytes: bool = False,
Expand Down
34 changes: 14 additions & 20 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
[metadata]
name = pytesseract
version = attr: pytesseract.__version__
author = Samuel Hoffstaetter
author_email = samuel@hoffstaetter.com
maintainer = Matthias Lee
maintainer_email = pytesseract@madmaze.net
description = Python-tesseract is a python wrapper for Google's Tesseract-OCR
long_description = file: README.rst
long_description_content_type = text/x-rst
license = Apache License 2.0
license_file = LICENSE
keywords = python-tesseract OCR Python
url = https://github.com/madmaze/pytesseract
author = Samuel Hoffstaetter
author_email = samuel@hoffstaetter.com
maintainer = Matthias Lee
maintainer_email = pytesseract@madmaze.net
license = Apache-2.0
license_files = LICENSE
classifiers =
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
keywords = python-tesseract OCR Python
[options]
packages = find:
include_package_data = True
install_requires =
packaging>=21.3
Pillow>=8.0.0
python_requires = >=3.8
[options.entry_points]
console_scripts =
pytesseract = pytesseract.pytesseract:main
packaging>=21.3
python_requires = >=3.9
include_package_data = True
[options.packages.find]
exclude =
tests*
testing*
[options.entry_points]
console_scripts =
pytesseract = pytesseract.pytesseract:main
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from setuptools import setup


Expand Down
6 changes: 4 additions & 2 deletions tests/pytesseract_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import partial
from glob import iglob
from multiprocessing import Pool
Expand Down Expand Up @@ -293,7 +295,7 @@ def test_image_to_alto_xml_support(test_file):
TESSERACT_VERSION[:2] >= (3, 5),
reason='requires tesseract < 3.05',
)
def test_image_to_data__pandas_support(test_file_small):
def test_image_to_data_pandas_support(test_file_small):
with pytest.raises(TSVNotSupported):
image_to_data(test_file_small, output_type=Output.DATAFRAME)

Expand All @@ -303,7 +305,7 @@ def test_image_to_data__pandas_support(test_file_small):
reason='requires tesseract >= 3.05',
)
@pytest.mark.skipif(pandas_installed is False, reason='requires pandas')
def test_image_to_data__pandas_output(test_file_small):
def test_image_to_data_pandas_output(test_file_small):
"""Test and compare the type and meta information of the result."""
result = image_to_data(test_file_small, output_type=Output.DATAFRAME)
assert isinstance(result, pandas.DataFrame)
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py, py-slow
envlist = py, pandas

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

[testenv:py-slow]
[testenv:pandas]
deps =
numpy
pandas
-r{toxinidir}/requirements-dev.txt
passenv = *
commands =
python -bb -m pytest {posargs:tests}

0 comments on commit 6e4f31c

Please sign in to comment.