diff --git a/src/ocrmypdf/__init__.py b/src/ocrmypdf/__init__.py index 9bbd2aa3..8d779a95 100644 --- a/src/ocrmypdf/__init__.py +++ b/src/ocrmypdf/__init__.py @@ -15,16 +15,8 @@ # You should have received a copy of the GNU General Public License # along with OCRmyPDF. If not, see . -import pkg_resources - -PROGRAM_NAME = 'ocrmypdf' - -# Official PEP 396 -__version__ = pkg_resources.get_distribution('ocrmypdf').version - -VERSION = __version__ - from . import helpers, hocrtransform, leptonica, pdfa, pdfinfo +from ._version import PROGRAM_NAME, __version__ from .api import Verbosity, configure_logging, ocr from .exceptions import ( BadArgsError, diff --git a/src/ocrmypdf/_pipeline.py b/src/ocrmypdf/_pipeline.py index 0a846bfd..7af59c02 100644 --- a/src/ocrmypdf/_pipeline.py +++ b/src/ocrmypdf/_pipeline.py @@ -26,7 +26,9 @@ import pikepdf from pikepdf.models.metadata import encode_pdf_date from PIL import Image -from . import PROGRAM_NAME, VERSION, leptonica +from . import leptonica +from ._version import PROGRAM_NAME +from ._version import __version__ as VERSION from .exceptions import ( DpiError, EncryptedPdfError, diff --git a/src/ocrmypdf/_sync.py b/src/ocrmypdf/_sync.py index 5cb7bd8a..ccedbdc6 100644 --- a/src/ocrmypdf/_sync.py +++ b/src/ocrmypdf/_sync.py @@ -27,7 +27,6 @@ from tempfile import mkdtemp from tqdm import tqdm -from . import __version__ from ._graft import OcrGrafter from ._jobcontext import PDFContext, cleanup_working_files, make_logger from ._pipeline import ( diff --git a/src/ocrmypdf/_version.py b/src/ocrmypdf/_version.py new file mode 100644 index 00000000..430f76e7 --- /dev/null +++ b/src/ocrmypdf/_version.py @@ -0,0 +1,24 @@ +# © 2017 James R. Barlow: github.com/jbarlow83 +# +# This file is part of OCRmyPDF. +# +# OCRmyPDF is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OCRmyPDF is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OCRmyPDF. If not, see . + + +import pkg_resources + +PROGRAM_NAME = 'ocrmypdf' + +# Official PEP 396 +__version__ = pkg_resources.get_distribution('ocrmypdf').version diff --git a/src/ocrmypdf/cli.py b/src/ocrmypdf/cli.py index 2d5b6788..d8a55481 100644 --- a/src/ocrmypdf/cli.py +++ b/src/ocrmypdf/cli.py @@ -17,7 +17,8 @@ import argparse -from . import PROGRAM_NAME, VERSION +from ._version import PROGRAM_NAME as _PROGRAM_NAME +from ._version import __version__ as _VERSION def numeric(basetype, min_=None, max_=None): @@ -54,7 +55,7 @@ class ArgumentParser(argparse.ArgumentParser): parser = ArgumentParser( - prog=PROGRAM_NAME, + prog=_PROGRAM_NAME, fromfile_prefix_chars='@', formatter_class=argparse.RawDescriptionHelpFormatter, description="""\ @@ -167,7 +168,7 @@ parser.add_argument( parser.add_argument( '--version', action='version', - version=VERSION, + version=_VERSION, help="Print program version and exit", )