From 077b3c3e0fe2b3bf7b59b586ed8026ef154e3860 Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Tue, 11 Sep 2018 05:57:24 +0530 Subject: [PATCH] Fix setup.py --- camelot/cli.py | 2 ++ requirements-dev.txt | 10 +------- requirements.txt | 1 - setup.py | 57 +++++++++++++------------------------------- 4 files changed, 19 insertions(+), 51 deletions(-) diff --git a/camelot/cli.py b/camelot/cli.py index 709bfc3..80e04d6 100644 --- a/camelot/cli.py +++ b/camelot/cli.py @@ -3,6 +3,7 @@ from pprint import pprint import click +from . import __version__ from .io import read_pdf from .plotting import plot_geometry from .utils import validate_input, remove_extra @@ -17,6 +18,7 @@ class Mutex(click.Option): @click.command() +@click.version_option(version=__version__) @click.option("-p", "--pages", default="1", help="Comma-separated page numbers" " to parse. Example: 1,3,4 or 1,4-end") @click.option("-o", "--output", help="Output filepath.") diff --git a/requirements-dev.txt b/requirements-dev.txt index d907a0b..388f751 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,11 +1,3 @@ -click==6.7 -matplotlib==2.2.3 -numpy==1.13.3 -opencv-python==3.4.2.17 -pandas==0.23.4 -pdfminer==20140328 -Pillow==5.2.0 -PyPDF2==1.26.0 pytest==3.8.0 pytest-runner==4.2 -Sphinx==1.8.0b1 \ No newline at end of file +Sphinx==1.7.9 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d1a33b7..a9b0931 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ numpy==1.13.3 opencv-python==3.4.2.17 pandas==0.23.4 pdfminer==20140328 -Pillow==5.2.0 PyPDF2==1.26.0 \ No newline at end of file diff --git a/setup.py b/setup.py index c438897..d37bcf2 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,16 @@ +import os +from setuptools import find_packages from pkg_resources import parse_version -import camelot +here = os.path.abspath(os.path.dirname(__file__)) +about = {} +with open(os.path.join(here, 'camelot', '__version__.py'), 'r') as f: + exec(f.read(), about) + +# TODO: Move these to __version__.py NAME = 'camelot' -VERSION = camelot.__version__ +VERSION = about['__version__'] DESCRIPTION = 'PDF Table Parsing for Humans' with open('README.md') as f: LONG_DESCRIPTION = f.read() @@ -12,27 +19,6 @@ AUTHOR = 'Vinayak Mehta' AUTHOR_EMAIL = 'vmehta94@gmail.com' LICENSE = 'MIT License' -opencv_min_version = '2.4.8' - - -def get_opencv_status(): - """ - Returns a dictionary containing a boolean specifying whether OpenCV - is up-to-date, along with the version string (empty string if - not installed). - """ - opencv_status = {} - try: - import cv2 - opencv_version = cv2.__version__ - opencv_status['up_to_date'] = parse_version( - opencv_version) >= parse_version(opencv_min_version) - opencv_status['version'] = opencv_version - except ImportError: - opencv_status['up_to_date'] = False - opencv_status['version'] = "" - return opencv_status - def setup_package(): reqs = [] @@ -40,12 +26,10 @@ def setup_package(): for line in f: reqs.append(line.strip()) - extra_reqs = { - 'dev': [] - } + dev_reqs = [] with open('requirements-dev.txt', 'r') as f: for line in f: - extra_reqs['dev'].append(line.strip()) + dev_reqs.append(line.strip()) metadata = dict(name=NAME, version=VERSION, @@ -55,9 +39,11 @@ def setup_package(): author=AUTHOR, author_email=AUTHOR_EMAIL, license=LICENSE, - packages=['camelot'], + packages=find_packages(exclude=('tests',)), install_requires=reqs, - extra_requires=extra_reqs, + extras_require={ + 'dev': dev_reqs + }, entry_points={ 'console_scripts': [ 'camelot = camelot.cli:cli', @@ -75,19 +61,8 @@ def setup_package(): except: from distutils.core import setup - opencv_status = get_opencv_status() - opencv_req_str = "camelot requires OpenCV >= {0}.\n".format(opencv_min_version) - - if opencv_status['up_to_date'] is False: - if opencv_status['version']: - raise ImportError("Your installation of OpenCV {} is out-of-date.\n{}" - .format(opencv_status['version'], opencv_req_str)) - else: - raise ImportError("OpenCV is not installed.\n{}" - .format(opencv_req_str)) - setup(**metadata) if __name__ == '__main__': - setup_package() + setup_package() \ No newline at end of file