From 26e36422cc66e6ebff7dfacce116ac5deb661c5c Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 19 Jan 2016 15:07:21 -0800 Subject: [PATCH] More fiddling with version --- .gitignore | 1 + ocrmypdf/main.py | 7 ++----- requirements.txt | 2 +- setup.py | 31 +++++++++++++++++++++++++------ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 43e1c34e..1e47924e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ htmlcov/ .ipynb_checkpoints/ tests/cache/ tests/resources/private +ocrmypdf/version.py \ No newline at end of file diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index 5bdaa815..cefb1473 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -18,7 +18,6 @@ from PIL import Image from functools import partial - from ruffus import transform, suffix, merge, active_if, regex, jobs_limit, \ formatter, follows, split, collate, check_if_uptodate import ruffus.ruffus_exceptions as ruffus_exceptions @@ -31,15 +30,13 @@ from . import ghostscript from . import tesseract from . import qpdf from . import ExitCode +from . import version warnings.simplefilter('ignore', pypdf.utils.PdfReadWarning) BASEDIR = os.path.dirname(os.path.realpath(__file__)) -from setuptools_scm import get_version -VERSION = get_version() - # ------------- # External dependencies @@ -100,7 +97,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/requirements.txt b/requirements.txt index 80503533..f36dafe9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ ruffus>=2.6.3 Pillow>=2.4.0 reportlab>=3.1.44 PyPDF2>=1.25.1 -git+https://github.com/jbarlow83/img2pdf.git@e9bcce0afc3720752ca53a991db93f911a1df709#egg=img2pdf +git+https://github.com/jbarlow83/img2pdf.git@e9bcce0afc3720752ca53a991db93f911a1df709#egg=img2pdf-0.1.5.dev diff --git a/setup.py b/setup.py index 24afb679..df70829d 100644 --- a/setup.py +++ b/setup.py @@ -3,17 +3,32 @@ from __future__ import print_function, unicode_literals from setuptools import setup -from subprocess import Popen, STDOUT, check_output, CalledProcessError -from string import Template +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. @@ -179,11 +194,11 @@ if 'upload' in sys.argv[1:]: print('Use twine to upload the package - setup.py upload is insecure') sys.exit(1) -install_requires = open('requirements.txt').read().splitlines() 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', @@ -207,8 +222,13 @@ setup( "Topic :: Text Processing :: Indexing", "Topic :: Text Processing :: Linguistic", ], - setup_requires=['setuptools_scm'], - install_requires=install_requires, + install_requires=[ + 'ruffus', + 'Pillow', + 'reportlab', + 'PyPDF2', + 'img2pdf' + ], tests_require=tests_require, entry_points={ 'console_scripts': [ @@ -216,5 +236,4 @@ setup( ], }, include_package_data=True, - use_scm_version=True, zip_safe=False)