From 37c508f3f884e7203d6053ea0d319cf2e5eaf8b6 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 19 Jan 2016 16:07:52 -0800 Subject: [PATCH] Better versioning: no silly version files, but wrong ver in development Small price to pay. --- ocrmypdf/main.py | 7 +++++-- setup.py | 21 ++++----------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index cefb1473..c8ade0ae 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -30,7 +30,10 @@ from . import ghostscript from . import tesseract from . import qpdf from . import ExitCode -from . import version + +import pkg_resources + +VERSION = pkg_resources.get_distribution('ocrmypdf').version warnings.simplefilter('ignore', pypdf.utils.PdfReadWarning) @@ -97,7 +100,7 @@ check_pil_encoder('zlib', 'PNG') parser = cmdline.get_argparse( prog="ocrmypdf", description="Generate searchable PDF file from an image-only PDF file.", - version=version.__version__, + version=VERSION, fromfile_prefix_chars='@', ignored_args=[ 'touch_files_only', 'recreate_database', 'checksum_file_name', diff --git a/setup.py b/setup.py index df70829d..187e8ddb 100644 --- a/setup.py +++ b/setup.py @@ -7,28 +7,12 @@ from subprocess import STDOUT, check_output, CalledProcessError from collections.abc import Mapping import re import sys -import os if sys.version_info < (3, 4): print("Python 3.4 or newer is required") sys.exit(1) -version_py = os.path.join(os.path.dirname(__file__), 'ocrmypdf', 'version.py') -try: - version_git = check_output(["git", "describe"], - universal_newlines=True).rstrip() - version_git = version_git.replace('-g', '+n') - version_git = version_git.replace('-', '.dev') -except Exception: - with open(version_py, 'r') as fh: - version_git = fh.read().strip().split('=')[-1].replace('"', '') - -version_msg = "# Do not edit this file" -with open(version_py, 'w') as fh: - fh.write('\n'.join([version_msg, '__version__="' + version_git + '"'])) - - missing_program = ''' The program '{program}' could not be executed or was not found on your system PATH. @@ -198,7 +182,6 @@ tests_require = open('test_requirements.txt').read().splitlines() setup( name='ocrmypdf', - version="{ver}".format(ver=version_git), description='OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched', url='https://github.com/jbarlow83/OCRmyPDF', author='James R. Barlow', @@ -222,6 +205,10 @@ setup( "Topic :: Text Processing :: Indexing", "Topic :: Text Processing :: Linguistic", ], + setup_requires=[ + 'setuptools_scm' + ], + use_scm_version={'version_scheme': 'post-release'}, install_requires=[ 'ruffus', 'Pillow',