diff --git a/redcap/__init__.py b/redcap/__init__.py index 39c209b..f4df935 100644 --- a/redcap/__init__.py +++ b/redcap/__init__.py @@ -4,6 +4,7 @@ __author__ = 'Scott Burns ' __license__ = 'MIT' __copyright__ = '2014, Vanderbilt University' +__version__ = '1.0.2' """ This module exposes the REDCap API through the Project class. Instantiate the @@ -18,4 +19,3 @@ class with the URL to your REDCap system along with an API key, probably from .project import Project from .request import RCRequest, RCAPIError, RedcapError -from .version import VERSION as __version__ diff --git a/redcap/version.py b/redcap/version.py deleted file mode 100644 index a98c726..0000000 --- a/redcap/version.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -__author__ = 'Scott Burns ' -__license__ = 'MIT' -__copyright__ = '2014, Vanderbilt University' - -VERSION = '1.0.2' diff --git a/setup.py b/setup.py index cece97d..dbe302b 100644 --- a/setup.py +++ b/setup.py @@ -5,21 +5,30 @@ __license__ = 'MIT' __copyright__ = '2014, Vanderbilt University' +import codecs import os +import re + +# Taken from vulture setup.py: https://github.com/jendrikseipp/vulture/blob/master/setup.py +def read(*parts): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, *parts), "r") as f: + return f.read() + +def find_version(*file_parts): + version_file = read(*file_parts) + version_match = re.search( + r"^__version__ = ['\"]([^'\"]*)['\"]$", version_file, re.M + ) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") try: from setuptools import setup except ImportError: from distutils.core import setup - -def get_version(): - base = os.path.dirname(__file__) - with open(os.path.join(base, 'redcap/version.py')) as f: - VERSION = None - exec(f.read()) - return VERSION - required = [ 'requests>=1.0.0', 'semantic-version>=2.3.1' @@ -37,7 +46,7 @@ def get_version(): description="""PyCap: Python interface to REDCap""", license='MIT', url='http://sburns.github.com/PyCap', - version=get_version(), + version=find_version("redcap", "__init__.py"), download_url='http://sburns.github.com/PyCap', long_description=long_desc, packages=['redcap'],