From b0eacd6586c9e8217f9b4924e7093ae976360e7d Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 28 Jun 2018 13:57:45 -0700 Subject: [PATCH] Add Python 3.7 support --- .travis.yml | 8 ++++++-- README.rst | 16 +++++++--------- docs/installation.rst | 2 +- setup.py | 1 + src/ocrmypdf/_unicodefun.py | 5 +++++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index d315722e..83e4bb5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,11 +36,15 @@ matrix: - os: linux sudo: required language: python - python: 3.5 + python: "3.5" - os: linux sudo: required language: python - python: 3.6 + python: "3.6" + - os: linux + sudo: required + language: python + python: "3.7-dev" - os: osx osx_image: xcode8 language: generic diff --git a/README.rst b/README.rst index fd5031a0..dc8872d7 100644 --- a/README.rst +++ b/README.rst @@ -4,10 +4,10 @@ OCRmyPDF .. image:: https://travis-ci.org/jbarlow83/OCRmyPDF.svg?branch=master :target: https://travis-ci.org/jbarlow83/OCRmyPDF -.. image:: https://img.shields.io/pypi/v/ocrmypdf.svg +.. image:: https://img.shields.io/pypi/v/ocrmypdf.svg :target: https://pypi.org/project/ocrmypdf/ -.. image:: https://img.shields.io/homebrew/v/ocrmypdf.svg +.. image:: https://img.shields.io/homebrew/v/ocrmypdf.svg :alt: homebrew :target: http://brewformulas.org/Ocrmypdf @@ -53,7 +53,7 @@ Motivation I searched the web for a free command line tool to OCR PDF files on Linux/UNIX: I found many, but none of them were really satisfying. -- Either they produced PDF files with misplaced text under the image (making copy/paste impossible) +- Either they produced PDF files with misplaced text under the image (making copy/paste impossible) - Or they did not handle accents and multilingual characters - Or they changed the resolution of the embedded images - Or they generated ridiculously large PDF files @@ -62,7 +62,7 @@ Linux/UNIX: I found many, but none of them were really satisfying. - On top of that none of them produced PDF/A files (format dedicated for long time storage) ...so I decided to develop my own tool (using various existing scripts -as an inspiration). +as an inspiration). Installation ------------ @@ -96,7 +96,7 @@ you can often find packages that provide language packs: # Debian/Ubuntu users apt-get install tesseract-ocr-chi-sim # Example: Install Chinese Simplified language back - + You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as to what languages it should search for. Multiple languages can be requested. @@ -125,9 +125,7 @@ If you detect an issue, please: Requirements ------------ -Runs on CPython 3.6, and requires external program installations of Ghostscript, Tesseract OCR, QPDF, and Leptonica. ocrmypdf is pure Python, but uses CFFI to portably generate library bindings. - -Python 3.5 is also supported. +Runs on CPython 3.5, 3.6 and 3.7. Requires external program installations of Ghostscript, Tesseract OCR, QPDF, and Leptonica. ocrmypdf is pure Python, but uses CFFI to portably generate library bindings. Press & Media ------------- @@ -141,7 +139,7 @@ Press & Media License ------- -The OCRmyPDF software is licensed under the GNU GPLv3. Certain files are covered by other licenses, as noted in their source files. +The OCRmyPDF software is licensed under the GNU GPLv3. Certain files are covered by other licenses, as noted in their source files. The license for each test file varies, and is noted in tests/resources/README.rst. The documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA 4.0). diff --git a/docs/installation.rst b/docs/installation.rst index 446f9cb9..8b0149ad 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -168,7 +168,7 @@ Install or upgrade the required Homebrew packages, if any are missing: brew install libxml2 libffi leptonica brew install unpaper # optional -Python 3.5 and 3.6 are supported. +Python 3.5, 3.6 and 3.7 are supported. Install the required Tesseract OCR engine with the language packs you plan to use: diff --git a/setup.py b/setup.py index 0b098d1a..7793e749 100644 --- a/setup.py +++ b/setup.py @@ -221,6 +221,7 @@ setup( classifiers=[ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: End Users/Desktop", diff --git a/src/ocrmypdf/_unicodefun.py b/src/ocrmypdf/_unicodefun.py index a916077f..e80d3d21 100644 --- a/src/ocrmypdf/_unicodefun.py +++ b/src/ocrmypdf/_unicodefun.py @@ -40,6 +40,11 @@ import codecs def verify_python3_env(): """Ensures that the environment is good for unicode on Python 3.""" + + # PEP 538 changes in Python 3.7 should make this wrangling unnecessary + if sys.version_info[0:3] >= (3, 7, 0): + return + try: import locale fs_enc = codecs.lookup(locale.getpreferredencoding()).name